{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "<a target=\"_blank\" href=\"https://colab.research.google.com/github/TransformerLensOrg/TransformerLens/blob/main/demos/Head_Detector_Demo.ipynb\">\n",
        "  <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
        "</a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YquKKgs17NOv"
      },
      "source": [
        "# TransformerLens Head Detector Demo"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wKW2CqN-yZuY"
      },
      "source": [
        "A common technique in mechanistic interpretability of transformer-based neural networks is identification of specialized attention heads, based on the attention patterns elicited by one or more prompts. The most basic examples of such heads are: previous token head, duplicate token head, or induction head ([more info](https://dynalist.io/d/n2ZWtnoYHrU1s4vnFSAQ519J#z=_Jzi6YHRHKP1JziwdE02qdYZ)). Usually, such heads are identified manually, by through visualizations of attention patterns layer by layer, head by head, and trying to recognize the patterns by eye.\n",
        "\n",
        "The purpose of the `TransformerLens.head_detector` feature is to automate a part of that workflow. The pattern characterizing a head of particular type/function is specified as a `Tensor` being a `seq_len x seq_len` [lower triangular matrix](https://en.wikipedia.org/wiki/Triangular_matrix). It can be either passed to the `detect_head` function directly or by giving a string identifying of several pre-defined detection patterns."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3a53LkPTAjzB"
      },
      "source": [
        "## How to use this notebook\n",
        "\n",
        "Go to Runtime > Change Runtime Type and select GPU as the hardware accelerator.\n",
        "\n",
        "Tips for reading this Colab:\n",
        "\n",
        "* You can run all this code for yourself!\n",
        "* The graphs are interactive!\n",
        "* Use the table of contents pane in the sidebar to navigate\n",
        "* Collapse irrelevant sections with the dropdown arrows\n",
        "* Search the page using the search in the sidebar, not CTRL+F"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "nCWImh1S7fNx"
      },
      "source": [
        "## Setup (Ignore)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4LZeYL3XAc7T",
        "outputId": "680da02d-5ca8-4ab3-bc24-f2827f0fcd95"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Running as a Colab notebook\n",
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
            "Collecting git+https://github.com/TransformerLensOrg/TransformerLens.git\n",
            "  Cloning https://github.com/TransformerLensOrg/TransformerLens.git to /tmp/pip-req-build-v3x96q_b\n",
            "  Running command git clone --filter=blob:none --quiet https://github.com/TransformerLensOrg/TransformerLens.git /tmp/pip-req-build-v3x96q_b\n",
            "  Resolved https://github.com/TransformerLensOrg/TransformerLens.git to commit 0ffcc8ad647d9e991f4c2596557a9d7475617773\n",
            "  Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
            "  Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
            "  Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
            "Requirement already satisfied: datasets>=2.7.1 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (2.12.0)\n",
            "Requirement already satisfied: einops>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (0.6.1)\n",
            "Requirement already satisfied: fancy-einsum>=0.0.3 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (0.0.3)\n",
            "Requirement already satisfied: jaxtyping>=0.2.11 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (0.2.15)\n",
            "Requirement already satisfied: numpy>=1.23 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (1.24.3)\n",
            "Requirement already satisfied: pandas>=1.1.5 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (1.5.3)\n",
            "Requirement already satisfied: rich>=12.6.0 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (13.3.4)\n",
            "Requirement already satisfied: torch>=1.10 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (2.0.0+cu118)\n",
            "Requirement already satisfied: tqdm>=4.64.1 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (4.65.0)\n",
            "Requirement already satisfied: transformers>=4.25.1 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (4.28.1)\n",
            "Requirement already satisfied: wandb>=0.13.5 in /usr/local/lib/python3.10/dist-packages (from transformer-lens==0.0.0) (0.15.0)\n",
            "Requirement already satisfied: pyarrow>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (9.0.0)\n",
            "Requirement already satisfied: dill<0.3.7,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (0.3.6)\n",
            "Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (2.27.1)\n",
            "Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (3.2.0)\n",
            "Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (0.70.14)\n",
            "Requirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (2023.4.0)\n",
            "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (3.8.4)\n",
            "Requirement already satisfied: huggingface-hub<1.0.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (0.14.1)\n",
            "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (23.1)\n",
            "Requirement already satisfied: responses<0.19 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (0.18.0)\n",
            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets>=2.7.1->transformer-lens==0.0.0) (6.0)\n",
            "Requirement already satisfied: typeguard>=2.13.3 in /usr/local/lib/python3.10/dist-packages (from jaxtyping>=0.2.11->transformer-lens==0.0.0) (2.13.3)\n",
            "Requirement already satisfied: typing-extensions>=3.7.4.1 in /usr/local/lib/python3.10/dist-packages (from jaxtyping>=0.2.11->transformer-lens==0.0.0) (4.5.0)\n",
            "Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.1.5->transformer-lens==0.0.0) (2.8.2)\n",
            "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.1.5->transformer-lens==0.0.0) (2022.7.1)\n",
            "Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=12.6.0->transformer-lens==0.0.0) (2.2.0)\n",
            "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=12.6.0->transformer-lens==0.0.0) (2.14.0)\n",
            "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch>=1.10->transformer-lens==0.0.0) (3.12.0)\n",
            "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.10->transformer-lens==0.0.0) (1.11.1)\n",
            "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.10->transformer-lens==0.0.0) (3.1)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.10->transformer-lens==0.0.0) (3.1.2)\n",
            "Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.10->transformer-lens==0.0.0) (2.0.0)\n",
            "Requirement already satisfied: cmake in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch>=1.10->transformer-lens==0.0.0) (3.25.2)\n",
            "Requirement already satisfied: lit in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch>=1.10->transformer-lens==0.0.0) (16.0.2)\n",
            "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->transformer-lens==0.0.0) (2022.10.31)\n",
            "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->transformer-lens==0.0.0) (0.13.3)\n",
            "Requirement already satisfied: Click!=8.0.0,>=7.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (8.1.3)\n",
            "Requirement already satisfied: GitPython!=3.1.29,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (3.1.31)\n",
            "Requirement already satisfied: psutil>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (5.9.5)\n",
            "Requirement already satisfied: sentry-sdk>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (1.21.1)\n",
            "Requirement already satisfied: docker-pycreds>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (0.4.0)\n",
            "Requirement already satisfied: pathtools in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (0.1.2)\n",
            "Requirement already satisfied: setproctitle in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (1.3.2)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (67.7.2)\n",
            "Requirement already satisfied: appdirs>=1.4.3 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (1.4.4)\n",
            "Requirement already satisfied: protobuf!=4.21.0,<5,>=3.19.0 in /usr/local/lib/python3.10/dist-packages (from wandb>=0.13.5->transformer-lens==0.0.0) (3.20.3)\n",
            "Requirement already satisfied: six>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from docker-pycreds>=0.4.0->wandb>=0.13.5->transformer-lens==0.0.0) (1.16.0)\n",
            "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (23.1.0)\n",
            "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (2.0.12)\n",
            "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (6.0.4)\n",
            "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (4.0.2)\n",
            "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (1.9.2)\n",
            "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (1.3.3)\n",
            "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets>=2.7.1->transformer-lens==0.0.0) (1.3.1)\n",
            "Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/lib/python3.10/dist-packages (from GitPython!=3.1.29,>=1.0.0->wandb>=0.13.5->transformer-lens==0.0.0) (4.0.10)\n",
            "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py<3.0.0,>=2.2.0->rich>=12.6.0->transformer-lens==0.0.0) (0.1.2)\n",
            "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets>=2.7.1->transformer-lens==0.0.0) (1.26.15)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets>=2.7.1->transformer-lens==0.0.0) (2022.12.7)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets>=2.7.1->transformer-lens==0.0.0) (3.4)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.10->transformer-lens==0.0.0) (2.1.2)\n",
            "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.10->transformer-lens==0.0.0) (1.3.0)\n",
            "Requirement already satisfied: smmap<6,>=3.0.1 in /usr/local/lib/python3.10/dist-packages (from gitdb<5,>=4.0.1->GitPython!=3.1.29,>=1.0.0->wandb>=0.13.5->transformer-lens==0.0.0) (5.0.0)\n",
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
            "Collecting git+https://github.com/neelnanda-io/neel-plotly.git\n",
            "  Cloning https://github.com/neelnanda-io/neel-plotly.git to /tmp/pip-req-build-u8mujxc3\n",
            "  Running command git clone --filter=blob:none --quiet https://github.com/neelnanda-io/neel-plotly.git /tmp/pip-req-build-u8mujxc3\n",
            "  Resolved https://github.com/neelnanda-io/neel-plotly.git to commit 6dc096fdc575da978d3e56489f2347d95cd397e7\n",
            "  Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "Requirement already satisfied: einops in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (0.6.1)\n",
            "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (1.24.3)\n",
            "Requirement already satisfied: torch in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (2.0.0+cu118)\n",
            "Requirement already satisfied: plotly in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (5.13.1)\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (4.65.0)\n",
            "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from neel-plotly==0.0.0) (1.5.3)\n",
            "Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->neel-plotly==0.0.0) (2.8.2)\n",
            "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->neel-plotly==0.0.0) (2022.7.1)\n",
            "Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from plotly->neel-plotly==0.0.0) (8.2.2)\n",
            "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (3.12.0)\n",
            "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (4.5.0)\n",
            "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (1.11.1)\n",
            "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (3.1)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (3.1.2)\n",
            "Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.10/dist-packages (from torch->neel-plotly==0.0.0) (2.0.0)\n",
            "Requirement already satisfied: cmake in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch->neel-plotly==0.0.0) (3.25.2)\n",
            "Requirement already satisfied: lit in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch->neel-plotly==0.0.0) (16.0.2)\n",
            "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas->neel-plotly==0.0.0) (1.16.0)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch->neel-plotly==0.0.0) (2.1.2)\n",
            "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch->neel-plotly==0.0.0) (1.3.0)\n",
            "\n",
            "## Installing the NodeSource Node.js 16.x repo...\n",
            "\n",
            "\n",
            "## Populating apt-get cache...\n",
            "\n",
            "+ apt-get update\n",
            "Hit:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease\n",
            "Hit:2 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease\n",
            "Hit:3 https://deb.nodesource.com/node_16.x focal InRelease\n",
            "Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]\n",
            "Hit:5 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease\n",
            "Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease\n",
            "Get:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]\n",
            "Hit:8 http://ppa.launchpad.net/cran/libgit2/ubuntu focal InRelease\n",
            "Hit:9 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease\n",
            "Get:10 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]\n",
            "Hit:11 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease\n",
            "Hit:12 http://ppa.launchpad.net/ubuntugis/ppa/ubuntu focal InRelease\n",
            "Fetched 336 kB in 2s (202 kB/s)\n",
            "Reading package lists... Done\n",
            "\n",
            "## Confirming \"focal\" is supported...\n",
            "\n",
            "+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_16.x/dists/focal/Release'\n",
            "\n",
            "## Adding the NodeSource signing key to your keyring...\n",
            "\n",
            "+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null\n",
            "\n",
            "## Creating apt sources list file for the NodeSource Node.js 16.x repo...\n",
            "\n",
            "+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main' > /etc/apt/sources.list.d/nodesource.list\n",
            "+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main' >> /etc/apt/sources.list.d/nodesource.list\n",
            "\n",
            "## Running `apt-get update` for you...\n",
            "\n",
            "+ apt-get update\n",
            "Hit:1 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease\n",
            "Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease\n",
            "Hit:3 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease\n",
            "Hit:4 https://deb.nodesource.com/node_16.x focal InRelease\n",
            "Hit:5 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease\n",
            "Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease\n",
            "Hit:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease\n",
            "Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]\n",
            "Hit:9 http://ppa.launchpad.net/cran/libgit2/ubuntu focal InRelease\n",
            "Hit:10 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease\n",
            "Hit:11 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease\n",
            "Hit:12 http://ppa.launchpad.net/ubuntugis/ppa/ubuntu focal InRelease\n",
            "Fetched 108 kB in 1s (73.2 kB/s)\n",
            "Reading package lists... Done\n",
            "\n",
            "## Run `\u001b[1msudo apt-get install -y nodejs\u001b[m` to install Node.js 16.x and npm\n",
            "## You may also need development tools to build native addons:\n",
            "     sudo apt-get install gcc g++ make\n",
            "## To install the Yarn package manager, run:\n",
            "     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null\n",
            "     echo \"deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list\n",
            "     sudo apt-get update && sudo apt-get install yarn\n",
            "\n",
            "\n",
            "Reading package lists... Done\n",
            "Building dependency tree       \n",
            "Reading state information... Done\n",
            "nodejs is already the newest version (16.20.0-deb-1nodesource1).\n",
            "0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.\n",
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
            "Collecting git+https://github.com/TransformerLensOrg/PySvelte.git\n",
            "  Cloning https://github.com/TransformerLensOrg/PySvelte.git to /tmp/pip-req-build-09ycdh0j\n",
            "  Running command git clone --filter=blob:none --quiet https://github.com/TransformerLensOrg/PySvelte.git /tmp/pip-req-build-09ycdh0j\n",
            "  Resolved https://github.com/TransformerLensOrg/PySvelte.git to commit 8410eae58503df0a293857a61a1a11ca35f86525\n",
            "  Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "Requirement already satisfied: einops in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (0.6.1)\n",
            "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (1.24.3)\n",
            "Requirement already satisfied: torch in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (2.0.0+cu118)\n",
            "Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (2.12.0)\n",
            "Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (4.28.1)\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (4.65.0)\n",
            "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (1.5.3)\n",
            "Requirement already satisfied: typeguard~=2.0 in /usr/local/lib/python3.10/dist-packages (from PySvelte==1.0.0) (2.13.3)\n",
            "Requirement already satisfied: pyarrow>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (9.0.0)\n",
            "Requirement already satisfied: dill<0.3.7,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (0.3.6)\n",
            "Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (2.27.1)\n",
            "Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (3.2.0)\n",
            "Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (0.70.14)\n",
            "Requirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (2023.4.0)\n",
            "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (3.8.4)\n",
            "Requirement already satisfied: huggingface-hub<1.0.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (0.14.1)\n",
            "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (23.1)\n",
            "Requirement already satisfied: responses<0.19 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (0.18.0)\n",
            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets->PySvelte==1.0.0) (6.0)\n",
            "Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->PySvelte==1.0.0) (2.8.2)\n",
            "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->PySvelte==1.0.0) (2022.7.1)\n",
            "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (3.12.0)\n",
            "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (4.5.0)\n",
            "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (1.11.1)\n",
            "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (3.1)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (3.1.2)\n",
            "Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.10/dist-packages (from torch->PySvelte==1.0.0) (2.0.0)\n",
            "Requirement already satisfied: cmake in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch->PySvelte==1.0.0) (3.25.2)\n",
            "Requirement already satisfied: lit in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch->PySvelte==1.0.0) (16.0.2)\n",
            "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers->PySvelte==1.0.0) (2022.10.31)\n",
            "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /usr/local/lib/python3.10/dist-packages (from transformers->PySvelte==1.0.0) (0.13.3)\n",
            "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (23.1.0)\n",
            "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (2.0.12)\n",
            "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (6.0.4)\n",
            "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (4.0.2)\n",
            "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (1.9.2)\n",
            "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (1.3.3)\n",
            "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets->PySvelte==1.0.0) (1.3.1)\n",
            "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas->PySvelte==1.0.0) (1.16.0)\n",
            "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets->PySvelte==1.0.0) (1.26.15)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets->PySvelte==1.0.0) (2022.12.7)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets->PySvelte==1.0.0) (3.4)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch->PySvelte==1.0.0) (2.1.2)\n",
            "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch->PySvelte==1.0.0) (1.3.0)\n",
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
            "Requirement already satisfied: typeguard==2.13.3 in /usr/local/lib/python3.10/dist-packages (2.13.3)\n",
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
            "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (4.5.0)\n"
          ]
        }
      ],
      "source": [
        "# NBVAL_IGNORE_OUTPUT\n",
        "# Janky code to do different setup when run in a Colab notebook vs VSCode\n",
        "import os\n",
        "\n",
        "DEVELOPMENT_MODE = True\n",
        "IN_GITHUB = os.getenv(\"GITHUB_ACTIONS\") == \"true\"\n",
        "try:\n",
        "    import google.colab\n",
        "    IN_COLAB = True\n",
        "    print(\"Running as a Colab notebook\")\n",
        "except:\n",
        "    IN_COLAB = False\n",
        "    print(\"Running as a Jupyter notebook - intended for development only!\")\n",
        "    from IPython import get_ipython\n",
        "\n",
        "    ipython = get_ipython()\n",
        "    # Code to automatically update the HookedTransformer code as its edited without restarting the kernel\n",
        "    ipython.magic(\"load_ext autoreload\")\n",
        "    ipython.magic(\"autoreload 2\")\n",
        "\n",
        "if IN_COLAB or IN_GITHUB:\n",
        "    %pip install git+https://github.com/TransformerLensOrg/TransformerLens.git\n",
        "    # Install Neel's personal plotting utils\n",
        "    %pip install git+https://github.com/neelnanda-io/neel-plotly.git\n",
        "    # Install another version of node that makes PySvelte work way faster\n",
        "    !curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -; sudo apt-get install -y nodejs\n",
        "    %pip install git+https://github.com/neelnanda-io/PySvelte.git\n",
        "    # Needed for PySvelte to work, v3 came out and broke things...\n",
        "    %pip install typeguard==2.13.3\n",
        "    %pip install typing-extensions"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "id": "LBjE0qm6Ahyf"
      },
      "outputs": [],
      "source": [
        "# Plotly needs a different renderer for VSCode/Notebooks vs Colab argh\n",
        "import plotly.io as pio\n",
        "\n",
        "if IN_COLAB or not DEBUG_MODE:\n",
        "    # Thanks to annoying rendering issues, Plotly graphics will either show up in colab OR Vscode depending on the renderer - this is bad for developing demos! Thus creating a debug mode.\n",
        "    pio.renderers.default = \"colab\"\n",
        "else:\n",
        "    pio.renderers.default = \"png\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "id": "ScWILAgIGt5O"
      },
      "outputs": [],
      "source": [
        "import torch\n",
        "import einops\n",
        "import pysvelte\n",
        "from tqdm import tqdm\n",
        "\n",
        "import transformer_lens\n",
        "from transformer_lens import HookedTransformer, ActivationCache\n",
        "from neel_plotly import line, imshow, scatter"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "13A_MpOwJBaJ",
        "outputId": "8b84df9b-886f-4205-cd51-0dfaf48d72d6"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "device = 'cuda'\n"
          ]
        }
      ],
      "source": [
        "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
        "print(f\"{device = }\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wLp6sCvBnXRn"
      },
      "source": [
        "### Some plotting utils"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "id": "Gw7D7_IKkR3y"
      },
      "outputs": [],
      "source": [
        "# Util for plotting head detection scores\n",
        "\n",
        "def plot_head_detection_scores(\n",
        "    scores: torch.Tensor,\n",
        "    zmin: float = -1,\n",
        "    zmax: float = 1,\n",
        "    xaxis: str = \"Head\",\n",
        "    yaxis: str = \"Layer\",\n",
        "    title: str = \"Head Matches\"\n",
        ") -> None:\n",
        "    imshow(scores, zmin=zmin, zmax=zmax, xaxis=xaxis, yaxis=yaxis, title=title)\n",
        "\n",
        "def plot_attn_pattern_from_cache(cache: ActivationCache, layer_i: int):\n",
        "    attention_pattern = cache[\"pattern\", layer_i, \"attn\"].squeeze(0)\n",
        "    attention_pattern = einops.rearrange(attention_pattern, \"heads seq1 seq2 -> seq1 seq2 heads\")\n",
        "    print(f\"Layer {layer_i} Attention Heads:\")\n",
        "    return pysvelte.AttentionMulti(tokens=model.to_str_tokens(prompt), attention=attention_pattern)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "eclSY10h7r4R"
      },
      "source": [
        "## Head detector"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QSVGddQDk1M6"
      },
      "source": [
        "Utils: these will be in `transformer_lens.utils` after merging the fork to the main repo"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "id": "4zQYJUU4kgPu"
      },
      "outputs": [],
      "source": [
        "def is_square(x: torch.Tensor) -> bool:\n",
        "    \"\"\"Checks if `x` is a square matrix.\"\"\"\n",
        "    return x.ndim == 2 and x.shape[0] == x.shape[1]\n",
        "\n",
        "def is_lower_triangular(x: torch.Tensor) -> bool:\n",
        "    \"\"\"Checks if `x` is a lower triangular matrix.\"\"\"\n",
        "    if not is_square(x):\n",
        "        return False\n",
        "    return x.equal(x.tril())"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "BCqH-TfXk49T"
      },
      "source": [
        "The code below is copy-pasted from the expanded (not yet merged) version of `transformer_lens.head_detector`.\n",
        "\n",
        "After merging the code below can be replaced with simply\n",
        "\n",
        "```py\n",
        "from transformer_lens.head_detector import *\n",
        "```\n",
        "\n",
        "(but please don't use star-imports in production ;))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "id": "5ikyL8-S7u2Z"
      },
      "outputs": [],
      "source": [
        "from collections import defaultdict\n",
        "import logging\n",
        "from typing import cast, Dict, List, Optional, Tuple, Union\n",
        "from typing_extensions import get_args, Literal\n",
        "\n",
        "import numpy as np\n",
        "import torch\n",
        "\n",
        "from transformer_lens import HookedTransformer, ActivationCache\n",
        "# from transformer_lens.utils import is_lower_triangular, is_square\n",
        "\n",
        "HeadName = Literal[\"previous_token_head\", \"duplicate_token_head\", \"induction_head\"]\n",
        "HEAD_NAMES = cast(List[HeadName], get_args(HeadName))\n",
        "ErrorMeasure = Literal[\"abs\", \"mul\"]\n",
        "\n",
        "LayerHeadTuple = Tuple[int, int]\n",
        "LayerToHead = Dict[int, List[int]]\n",
        "\n",
        "INVALID_HEAD_NAME_ERR = (\n",
        "    f\"detection_pattern must be a Tensor or one of head names: {HEAD_NAMES}; got %s\"\n",
        ")\n",
        "\n",
        "SEQ_LEN_ERR = (\n",
        "    \"The sequence must be non-empty and must fit within the model's context window.\"\n",
        ")\n",
        "\n",
        "DET_PAT_NOT_SQUARE_ERR = \"The detection pattern must be a lower triangular matrix of shape (sequence_length, sequence_length); sequence_length=%d; got detection patern of shape %s\"\n",
        "\n",
        "\n",
        "def detect_head(\n",
        "    model: HookedTransformer,\n",
        "    seq: Union[str, List[str]],\n",
        "    detection_pattern: Union[torch.Tensor, HeadName],\n",
        "    heads: Optional[Union[List[LayerHeadTuple], LayerToHead]] = None,\n",
        "    cache: Optional[ActivationCache] = None,\n",
        "    *,\n",
        "    exclude_bos: bool = False,\n",
        "    exclude_current_token: bool = False,\n",
        "    error_measure: ErrorMeasure = \"mul\",\n",
        ") -> torch.Tensor:\n",
        "    \"\"\"Searches the model (or a set of specific heads, for circuit analysis) for a particular type of attention head.\n",
        "    This head is specified by a detection pattern, a (sequence_length, sequence_length) tensor representing the attention pattern we expect that type of attention head to show.\n",
        "    The detection pattern can be also passed not as a tensor, but as a name of one of pre-specified types of attention head (see `HeadName` for available patterns), in which case the tensor is computed within the function itself.\n",
        "\n",
        "    There are two error measures available for quantifying the match between the detection pattern and the actual attention pattern.\n",
        "\n",
        "    1. `\"mul\"` (default) multiplies both tensors element-wise and divides the sum of the result by the sum of the attention pattern.\n",
        "    Typically, the detection pattern should in this case contain only ones and zeros, which allows a straightforward interpretation of the score:\n",
        "    how big fraction of this head's attention is allocated to these specific query-key pairs?\n",
        "    Using values other than 0 or 1 is not prohibited but will raise a warning (which can be disabled, of course).\n",
        "    2. `\"abs\"` calculates the mean element-wise absolute difference between the detection pattern and the actual attention pattern.\n",
        "    The \"raw result\" ranges from 0 to 2 where lower score corresponds to greater accuracy. Subtracting it from 1 maps that range to (-1, 1) interval,\n",
        "    with 1 being perfect match and -1 perfect mismatch.\n",
        "\n",
        "    **Which one should you use?** `\"abs\"` is likely better for quick or exploratory investigations. For precise examinations where you're trying to\n",
        "    reproduce as much functionality as possible or really test your understanding of the attention head, you probably want to switch to `\"abs\"`.\n",
        "\n",
        "    The advantage of `\"abs\"` is that you can make more precise predictions, and have that measured in the score.\n",
        "    You can predict, for instance, 0.2 attention to X, and 0.8 attention to Y, and your score will be better if your prediction is closer.\n",
        "    The \"mul\" metric does not allow this, you'll get the same score if attention is 0.2, 0.8 or 0.5, 0.5 or 0.8, 0.2.\n",
        "\n",
        "    Args:\n",
        "    ----------\n",
        "        model: Model being used.\n",
        "        seq: String or list of strings being fed to the model.\n",
        "        head_name: Name of an existing head in HEAD_NAMES we want to check. Must pass either a head_name or a detection_pattern, but not both!\n",
        "        detection_pattern: (sequence_length, sequence_length) Tensor representing what attention pattern corresponds to the head we're looking for **or** the name of a pre-specified head. Currently available heads are: `[\"previous_token_head\", \"duplicate_token_head\", \"induction_head\"]`.\n",
        "        heads: If specific attention heads is given here, all other heads' score is set to -1. Useful for IOI-style circuit analysis. Heads can be spacified as a list tuples (layer, head) or a dictionary mapping a layer to heads within that layer that we want to analyze.\n",
        "        cache: Include the cache to save time if you want.\n",
        "        exclude_bos: Exclude attention paid to the beginning of sequence token.\n",
        "        exclude_current_token: Exclude attention paid to the current token.\n",
        "        error_measure: `\"mul\"` for using element-wise multiplication (default). `\"abs\"` for using absolute values of element-wise differences as the error measure.\n",
        "\n",
        "    Returns:\n",
        "    ----------\n",
        "    A (n_layers, n_heads) Tensor representing the score for each attention head.\n",
        "\n",
        "    Example:\n",
        "    --------\n",
        "    .. code-block:: python\n",
        "\n",
        "        >>> from transformer_lens import HookedTransformer,  utils\n",
        "        >>> from transformer_lens.head_detector import detect_head\n",
        "        >>> import plotly.express as px\n",
        "\n",
        "        >>> def imshow(tensor, renderer=None, xaxis=\"\", yaxis=\"\", **kwargs):\n",
        "        >>>     px.imshow(utils.to_numpy(tensor), color_continuous_midpoint=0.0, color_continuous_scale=\"RdBu\", labels={\"x\":xaxis, \"y\":yaxis}, **kwargs).show(renderer)\n",
        "\n",
        "        >>> model = HookedTransformer.from_pretrained(\"gpt2-small\")\n",
        "        >>> sequence = \"This is a test sequence. This is a test sequence.\"\n",
        "\n",
        "        >>> attention_score = detect_head(model, sequence, \"previous_token_head\")\n",
        "        >>> imshow(attention_score, zmin=-1, zmax=1, xaxis=\"Head\", yaxis=\"Layer\", title=\"Previous Head Matches\")\n",
        "    \"\"\"\n",
        "\n",
        "    cfg = model.cfg\n",
        "    tokens = model.to_tokens(seq).to(cfg.device)\n",
        "    seq_len = tokens.shape[-1]\n",
        "    \n",
        "    # Validate error_measure\n",
        "    \n",
        "    assert error_measure in get_args(ErrorMeasure), f\"Invalid {error_measure=}; valid values are {get_args(ErrorMeasure)}\"\n",
        "\n",
        "    # Validate detection pattern if it's a string\n",
        "    if isinstance(detection_pattern, str):\n",
        "        assert detection_pattern in HEAD_NAMES, (\n",
        "            INVALID_HEAD_NAME_ERR % detection_pattern\n",
        "        )\n",
        "        if isinstance(seq, list):\n",
        "            batch_scores = [detect_head(model, seq, detection_pattern) for seq in seq]\n",
        "            return torch.stack(batch_scores).mean(0)\n",
        "        detection_pattern = cast(\n",
        "            torch.Tensor,\n",
        "            eval(f\"get_{detection_pattern}_detection_pattern(tokens.cpu())\"),\n",
        "        ).to(cfg.device)\n",
        "\n",
        "    # if we're using \"mul\", detection_pattern should consist of zeros and ones\n",
        "    if error_measure == \"mul\" and not set(detection_pattern.unique().tolist()).issubset(\n",
        "        {0, 1}\n",
        "    ):\n",
        "        logging.warning(\n",
        "            \"Using detection pattern with values other than 0 or 1 with error_measure 'mul'\"\n",
        "        )\n",
        "\n",
        "    # Validate inputs and detection pattern shape\n",
        "    assert 1 < tokens.shape[-1] < cfg.n_ctx, SEQ_LEN_ERR\n",
        "    assert (\n",
        "        is_lower_triangular(detection_pattern) and seq_len == detection_pattern.shape[0]\n",
        "    ), DET_PAT_NOT_SQUARE_ERR % (seq_len, detection_pattern.shape)\n",
        "\n",
        "    if cache is None:\n",
        "        _, cache = model.run_with_cache(tokens, remove_batch_dim=True)\n",
        "\n",
        "    if heads is None:\n",
        "        layer2heads = {\n",
        "            layer_i: list(range(cfg.n_heads)) for layer_i in range(cfg.n_layers)\n",
        "        }\n",
        "    elif isinstance(heads, list):\n",
        "        layer2heads = defaultdict(list)\n",
        "        for layer, head in heads:\n",
        "            layer2heads[layer].append(head)\n",
        "    else:\n",
        "        layer2heads = heads\n",
        "\n",
        "    matches = -torch.ones(cfg.n_layers, cfg.n_heads)\n",
        "\n",
        "    for layer, layer_heads in layer2heads.items():\n",
        "        # [n_heads q_pos k_pos]\n",
        "        layer_attention_patterns = cache[\"pattern\", layer, \"attn\"]\n",
        "        for head in layer_heads:\n",
        "            head_attention_pattern = layer_attention_patterns[head, :, :]\n",
        "            head_score = compute_head_attention_similarity_score(\n",
        "                head_attention_pattern,\n",
        "                detection_pattern=detection_pattern,\n",
        "                exclude_bos=exclude_bos,\n",
        "                exclude_current_token=exclude_current_token,\n",
        "                error_measure=error_measure,\n",
        "            )\n",
        "            matches[layer, head] = head_score\n",
        "    return matches\n",
        "\n",
        "\n",
        "# Previous token head\n",
        "def get_previous_token_head_detection_pattern(\n",
        "    tokens: torch.Tensor,  # [batch (1) x pos]\n",
        ") -> torch.Tensor:\n",
        "    \"\"\"Outputs a detection score for [previous token heads](https://dynalist.io/d/n2ZWtnoYHrU1s4vnFSAQ519J#z=0O5VOHe9xeZn8Ertywkh7ioc).\n",
        "\n",
        "    Args:\n",
        "      tokens: Tokens being fed to the model.\n",
        "    \"\"\"\n",
        "    detection_pattern = torch.zeros(tokens.shape[-1], tokens.shape[-1])\n",
        "    # Adds a diagonal of 1's below the main diagonal.\n",
        "    detection_pattern[1:, :-1] = torch.eye(tokens.shape[-1] - 1)\n",
        "    return torch.tril(detection_pattern)\n",
        "\n",
        "\n",
        "# Duplicate token head\n",
        "def get_duplicate_token_head_detection_pattern(\n",
        "    tokens: torch.Tensor,  # [batch (1) x pos]\n",
        ") -> torch.Tensor:\n",
        "    \"\"\"Outputs a detection score for [duplicate token heads](https://dynalist.io/d/n2ZWtnoYHrU1s4vnFSAQ519J#z=2UkvedzOnghL5UHUgVhROxeo).\n",
        "\n",
        "    Args:\n",
        "      sequence: String being fed to the model.\n",
        "    \"\"\"\n",
        "    # [pos x pos]\n",
        "    token_pattern = tokens.repeat(tokens.shape[-1], 1).numpy()\n",
        "\n",
        "    # If token_pattern[i][j] matches its transpose, then token j and token i are duplicates.\n",
        "    eq_mask = np.equal(token_pattern, token_pattern.T).astype(int)\n",
        "\n",
        "    np.fill_diagonal(\n",
        "        eq_mask, 0\n",
        "    )  # Current token is always a duplicate of itself. Ignore that.\n",
        "    detection_pattern = eq_mask.astype(int)\n",
        "    return torch.tril(torch.as_tensor(detection_pattern).float())\n",
        "\n",
        "\n",
        "# Induction head\n",
        "def get_induction_head_detection_pattern(\n",
        "    tokens: torch.Tensor,  # [batch (1) x pos]\n",
        ") -> torch.Tensor:\n",
        "    \"\"\"Outputs a detection score for [induction heads](https://dynalist.io/d/n2ZWtnoYHrU1s4vnFSAQ519J#z=_tFVuP5csv5ORIthmqwj0gSY).\n",
        "\n",
        "    Args:\n",
        "      sequence: String being fed to the model.\n",
        "    \"\"\"\n",
        "    duplicate_pattern = get_duplicate_token_head_detection_pattern(tokens)\n",
        "\n",
        "    # Shift all items one to the right\n",
        "    shifted_tensor = torch.roll(duplicate_pattern, shifts=1, dims=1)\n",
        "\n",
        "    # Replace first column with 0's\n",
        "    # we don't care about bos but shifting to the right moves the last column to the first,\n",
        "    # and the last column might contain non-zero values.\n",
        "    zeros_column = torch.zeros(duplicate_pattern.shape[0], 1)\n",
        "    result_tensor = torch.cat((zeros_column, shifted_tensor[:, 1:]), dim=1)\n",
        "    return torch.tril(result_tensor)\n",
        "\n",
        "\n",
        "def get_supported_heads() -> None:\n",
        "    \"\"\"Returns a list of supported heads.\"\"\"\n",
        "    print(f\"Supported heads: {HEAD_NAMES}\")\n",
        "\n",
        "\n",
        "def compute_head_attention_similarity_score(\n",
        "    attention_pattern: torch.Tensor,  # [q_pos k_pos]\n",
        "    detection_pattern: torch.Tensor,  # [seq_len seq_len] (seq_len == q_pos == k_pos)\n",
        "    *,\n",
        "    exclude_bos: bool,\n",
        "    exclude_current_token: bool,\n",
        "    error_measure: ErrorMeasure,\n",
        ") -> float:\n",
        "    \"\"\"Compute the similarity between `attention_pattern` and `detection_pattern`.\n",
        "\n",
        "    Args:\n",
        "      attention_pattern: Lower triangular matrix (Tensor) representing the attention pattern of a particular attention head.\n",
        "      detection_pattern: Lower triangular matrix (Tensor) representing the attention pattern we are looking for.\n",
        "      exclude_bos: `True` if the beginning-of-sentence (BOS) token should be omitted from comparison. `False` otherwise.\n",
        "      exclude_bcurrent_token: `True` if the current token at each position should be omitted from comparison. `False` otherwise.\n",
        "      error_measure: \"abs\" for using absolute values of element-wise differences as the error measure. \"mul\" for using element-wise multiplication (legacy code).\n",
        "    \"\"\"\n",
        "    assert is_square(\n",
        "        attention_pattern\n",
        "    ), f\"Attention pattern is not square; got shape {attention_pattern.shape}\"\n",
        "\n",
        "    # mul\n",
        "\n",
        "    if error_measure == \"mul\":\n",
        "        if exclude_bos:\n",
        "            attention_pattern[:, 0] = 0\n",
        "        if exclude_current_token:\n",
        "            attention_pattern.fill_diagonal_(0)\n",
        "        score = attention_pattern * detection_pattern\n",
        "        return (score.sum() / attention_pattern.sum()).item()\n",
        "\n",
        "    # abs\n",
        "\n",
        "    abs_diff = (attention_pattern - detection_pattern).abs()\n",
        "    assert (abs_diff - torch.tril(abs_diff).to(abs_diff.device)).sum() == 0\n",
        "\n",
        "    size = len(abs_diff)\n",
        "    if exclude_bos:\n",
        "        abs_diff[:, 0] = 0\n",
        "    if exclude_current_token:\n",
        "        abs_diff.fill_diagonal_(0)\n",
        "\n",
        "    return 1 - round((abs_diff.mean() * size).item(), 3)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Bw4CZS-tCH7u"
      },
      "source": [
        "## Using Head Detector For Premade Heads\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "A0iDohDUmS_r"
      },
      "source": [
        "Load the model"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "nIiUfx76I6a1",
        "outputId": "85bf4ea6-0c27-4f3f-dfe5-b173dd3b70e0"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "Using pad_token, but it is not set yet.\n"
          ]
        },
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Loaded pretrained model gpt2-small into HookedTransformer\n"
          ]
        }
      ],
      "source": [
        "model = HookedTransformer.from_pretrained(\"gpt2-small\", device=device)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cgqKW_kWmPWX"
      },
      "source": [
        "See what heads are supported out of the box"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "3i0kKYngmLru",
        "outputId": "72a44f58-8a6b-4551-bb38-ddc177f5fd25"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Supported heads: ('previous_token_head', 'duplicate_token_head', 'induction_head')\n"
          ]
        }
      ],
      "source": [
        "get_supported_heads()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "b88sGXh1mUvD"
      },
      "source": [
        "Let's test detecting previous token head in the following prompt."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "hncQfgF8CE_i",
        "outputId": "a925be04-74ed-4e9e-b02d-faf6d24026f0"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"aad3cc7e-5e88-46da-91fa-144209b4e4de\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"aad3cc7e-5e88-46da-91fa-144209b4e4de\")) {                    Plotly.newPlot(                        \"aad3cc7e-5e88-46da-91fa-144209b4e4de\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.10648977011442184,0.003712289733812213,0.07677427679300308,0.11293616890907288,0.14678862690925598,0.010825601406395435,0.1220034807920456,0.2950446903705597,0.10770056396722794,0.09157310426235199,0.07613879442214966,0.09622703492641449],[0.30665123462677,0.20951177179813385,0.135933056473732,0.08725038170814514,0.11102237552404404,0.0783601701259613,0.08768891543149948,0.10654613375663757,0.09167753905057907,0.07531337440013885,0.13703426718711853,0.03145909309387207],[0.2024618536233902,0.08947758376598358,0.5738268494606018,0.27506449818611145,0.2662709057331085,0.31229281425476074,0.10925403237342834,0.1454659402370453,0.2884611189365387,0.356710284948349,0.16172318160533905,0.09374849498271942],[0.04157334938645363,0.1383505016565323,0.35252463817596436,0.27449917793273926,0.05809944123029709,0.08266247808933258,0.2691973149776459,0.464389443397522,0.3132918179035187,0.16200488805770874,0.10538890957832336,0.20830459892749786],[0.22341911494731903,0.1659650057554245,0.05862327665090561,0.22474327683448792,0.0925237238407135,0.1645050197839737,0.12725454568862915,0.18057389557361603,0.05640153959393501,0.12580014765262604,0.05286509171128273,0.959446132183075],[0.04806021600961685,0.04009934514760971,0.1421913355588913,0.11878220736980438,0.16482211649417877,0.04368172958493233,0.1832980215549469,0.1340857446193695,0.05133207142353058,0.052541498094797134,0.11058834940195084,0.06625015288591385],[0.19785994291305542,0.05779643729329109,0.05686601251363754,0.06234264373779297,0.10065824538469315,0.10591387748718262,0.05632954090833664,0.13743284344673157,0.24996663630008698,0.04049943760037422,0.048565398901700974,0.16459988057613373],[0.25515079498291016,0.04800381511449814,0.04084881767630577,0.0928226113319397,0.07183399051427841,0.08144236356019974,0.056191686540842056,0.04256194457411766,0.12151440978050232,0.08072124421596527,0.04155319556593895,0.04424770921468735],[0.07119788974523544,0.04211723431944847,0.0818818062543869,0.055862344801425934,0.1412409394979477,0.1322406828403473,0.05117373540997505,0.231308713555336,0.08808998763561249,0.06737332046031952,0.07709396630525589,0.05718527361750603],[0.0921887680888176,0.04378826916217804,0.073247529566288,0.22627021372318268,0.04513043537735939,0.0742681473493576,0.04616398736834526,0.06710651516914368,0.06250540167093277,0.04528783634305,0.13486799597740173,0.043476417660713196],[0.07116371393203735,0.04701310768723488,0.04804273694753647,0.05175817385315895,0.07189011573791504,0.07765878736972809,0.04945413023233414,0.06474193930625916,0.04441310465335846,0.16862323880195618,0.05007004365324974,0.12114688754081726],[0.09764081239700317,0.06124501675367355,0.05091676115989685,0.14285169541835785,0.06970648467540741,0.04938124865293503,0.04869818314909935,0.06646085530519485,0.16441413760185242,0.04693547263741493,0.08922594040632248,0.11619057506322861]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Previous Head Matches\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('aad3cc7e-5e88-46da-91fa-144209b4e4de');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "prompt = \"The head detector feature for TransformerLens allows users to check for various common heads automatically, reducing the cost of discovery.\"\n",
        "head_scores = detect_head(model, prompt, \"previous_token_head\")\n",
        "plot_head_detection_scores(head_scores, title=\"Previous Head Matches\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "f_iFBhRRKQIF"
      },
      "source": [
        "We can see both L2H2 and L4H11 are doing a fair bit of previous token detection. Let's take a look and see if that pans out."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "id": "95mH2b43n0EZ"
      },
      "outputs": [],
      "source": [
        "_, cache = model.run_with_cache(prompt)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "S7bz-uZQKWpj",
        "outputId": "8bb120a6-3223-4b65-9c92-fd089d3f1d4e"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 2 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_4babede\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" head\",\n",
              "\" detector\",\n",
              "\" feature\",\n",
              "\" for\",\n",
              "\" Trans\",\n",
              "\"former\",\n",
              "\"Lens\",\n",
              "\" allows\",\n",
              "\" users\",\n",
              "\" to\",\n",
              "\" check\",\n",
              "\" for\",\n",
              "\" various\",\n",
              "\" common\",\n",
              "\" heads\",\n",
              "\" automatically\",\n",
              "\",\",\n",
              "\" reducing\",\n",
              "\" the\",\n",
              "\" cost\",\n",
              "\" of\",\n",
              "\" discovery\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"eJztmXdYFHfX98+vTNuZnZ3ZzgJLX7ooIlgQFRsqGhW7ImrEFhVFUAzYe8GuWAPGWLEkapTYjcbcatRorDFiSYgt3taYGI2+v8397/Ne7/W8T/G+n8ez117XzmE4szO/z3zP98wubNOxdduuCEZCYXjf7BHv54bXDQxPzo8PjwkM75eTm5fbe2hWTm7fbG++We/BI7JZfsSA3sOy2XZEfK2YQO+7RnxkTOCYwP+PMLx+82+/4F28i/9ADPlWfqz+GfNL4ZOZr0bcXLlpy+NzL+tfCX00P+6p+gifs0wy5pFZ7j4d26kx9LDne9Pb/r7v4l8j6n+6eXteZlLB5qKC0gvFl8YXDrxaYlpRcLlX/QONVixtWRQ2Iav9gZ6JNT8sSE4tC56s9jIvkh9KY+RYHK4OsjxqJblvh72Xin3e9nm8i3+uuFsyqPBH6/KWvabg/LKZ+/pFtS+ovrRX6vGprn6JP1S7PvZR5pqU8rbN3DVGb3Qp7h/l+sltImFbr+hQ3xtxLvPciD9jEgc/iy0ytdMrQ+sbw+TpqMBvqXlw+0+E9WnZGT183/b5vYu3E392FZfbzVUp6QN3t/9s6Lcpev8FvhuaXN77u7U8coKj+8KFdVOD2g6oaZ7S7RF30n5ROtu1mmLo3N66s+4Va4iw1VXd+omfJTBWflS9JCS60wHlb3aSuUL4OoEzhnx6sUF7e3N+slIjcrPysSHCleKanBXvv1Mva/Kt822f97v4r43xcRE7NFOXmPV1ltc1FrWs1d/tMC1s9HrrPj7cWcVl9N5jdppianeTv1Md5BvLj2ITtYXxESnTjsRXCqmG/XpU6xjjAZ+FYkKPsxpyrlHutN0Tmi66I6+3ez7kWfRo058+C9SK/fdqN5JyMyLNY9psMRmHNE/u7NuqKYiZeqjfNk/DRGP4m1pKaCn3SUSF9W1fj3fxnxPbGham1yloFjFwW71g07q1tfcnVMU+Sflh22fSHs8F9Ivja6k5X+WL1bp0DBmrufhdfKFtBlpDF3NHDfX5ulocTZbNthnSE9N3GZphnamQttHn8Ss8d7TimJtxt7TLjrWW7VFrXc3gdFNJL2wgeK63nBLX1TK44Ffh78kts9Sk1iPCbKEBtwq3RQ7wSTduU68Jn5sX1OjPtcJG+UYIp6UGbw5+rr7t6/Qu/n0hN+m7OBPdCp4Vmh309dxpiebopLCs6N/X54s/WxUo1Dtw5aQwwC5+zX2J18uZXB+aJ7WDSdw83AtF00r5ABpFzusGfiJ/znYJjoh5XC5/lMYH/ExKHfs8Xygv+QbyPh5L28kJ3+NKbqLFPdAUEFmqTRuQo58nIe+PCzk6syRkumt78cmox/aaxow4IJvuGVseKblLDxq+Cnil/p6W4T/GcETab48XPUKoaU14uVIctk89XAfVXOR429fvXfzb8aBhx0n7+Km2SeV9/PZMiYwu8QyVunqCV8/QEvQUyFb383Wox6+9lGl4DkeVCm4MpsYMaEv6Q2u0n0pyBa6HfE2PuAY0ze8u+obWJB6hPrfEp1II51YGLpH9yTXljpypjEfE6m/qHlUR6MfvCa5p9OkzWzuHt0eTgP6JD0JS7Jmjt8i59t+UG9WOcv3zx+Wo5sniD7LFmUJ3pe2ztpFHyJKtRXJY0DXLwsGfGMpcJ52NxpeE5pkaiA+l7omN5O1kiGOpYVHNDGO+dX3UVvPbvq7/26NXp4q5TdxTYkv2dovJ618eYkvfam4XdPHjH4RD+ljA0R0cs2jH5J6i2XQBFsiDuD/4I4oZ7vBVsAzHkY3iVNQBC8oPtLFhn5oKMr2PHnLDiVPfgo9rr22aWCL11l+hy/xi/Dn3g6GuP4jtjIecCwykwwrxE+7n2GkWp2WrZZp1V+pr/qXlghgjNSfHuYjAmpBk7MBf1SfDH84CvVy8xv+dW67l8V1JE0dHrtDUjsurN818X0iUKvGW5mf9a2KfRiniqmCEa/eNcSep632e+dUs7BjSV41JCwwZ08TSJluJTl3+bl74b4pGaSfePyKfMk9Z0duPH/swsKm5jvm6z8qVTjrbxIFBMnBt0T33E3oWMsElqXQH+ruVQi00jJ8KJrKCqwljYYhUTLpz8XYHHEb18C1UjmKU1nAWx5mvcFY63fIKqjgLeoPcnGrbDiv4r+x5UlFqG6UKWptXKxVKuqnUeM4yC+eYNgr95BNCb1wenEZeoNFcNaUL7DHWU9rx7Qwj5SaGM2S2vUQ4TJzGm6D6TdWSxT+M4+iTIL9AH4vDPkcc6roOv42/6WytDE3MCa2YXtSjh+X+ml1Ba+MafnfUsSr+hPUneTxXVfdO2GFxqbG/vVXqNPyB+1F8hO1tr8P/tPgiKWjlHvl8zPYAP2fhoB2+r5juHPftsaoaHs68co4wAPrBwdBgrifEwhJxHGmA/SUEUyEIDEDwGtod4qFK2IIn8nEs/y3kQTcoQ00MZpiCNxl7c18Jm0UFHqIgWIkm0Gu6L2zAZ7Vv+XGOV7wBnaII9yVJ8jW5CifD35Wx9Aqn4hmQLvSBDyCXjDUcAX8R5Emczl8mE6EVyYOD6DN8SRoIX6sL5AFcY+Ul3sXHqhn8dk7i29rfh5O+1Sxx0txwq+l2hwktd++9+sFDlyUq9adxzqVxupk3HxQ/mBzRsCHnaVBb7ZhYRoIX3I4ca22ZfsBsMycFCrakOC1iZPiXgkc1hvnqb3t9/lVjTlC33NG4rS25xxfShCF3g7ZbeskDbHOXXkKfygCdeB174EzQJH49RMMZoSepy20xASyAcMZVQ7yLStAOjvLFTKXiNICPYRhEwWK0W5TgBhokd6av4ZWbgIhvw2h4TYvVEojEVWoXvtT0mlMhUnwqfI1Oyp0Nm7mNsNXwirwht6gK57gubP9KnC4tggq+TNrFbSJfc74QTUehy2ghjpRWQpKUaiigD9QnZBI6I+2WzuOJdJzZB5mr2bVTwsbwZPUIuVgn1rdFw2zrgsBPmw+wrg//0hSsdVQeGhLjLpPCxA9Ue9RAerRXv+B9pl25B+UPbj/369N//sCnIdv8DcNOBdX1369+SaqJ67jABul8jNpBfhxS6cl1HYle9c6//T+i2Ll6l4U001uJ12VlbKnPQ5IvhJuLF5fDjwaAaKxBMPRzniMGUCGNF8nnUMYDJLAtAUpQF5a3Q23OH0eRIRxAHXBADDiQUzDCITgpriA+6AWH4RFQyIIBuFSm8ACS5d4cofMpMCadEAF/444LCkhwQuxCkuktFMEIlJlOLsCySMBCfKWPaDA9i42wAfnDRFSKXvMqdOb+FAPodf4yKoMWQg24h2/QVM0Gn1rbmgYIUcoP3AjhS/0bbYE2QTvlO9ofSTf9K+RF8gQaIhdZmtHJvovFkx4Pmptk9btnNCR+pAvNsTrUXN4t1dXJ1dZQIlR3nTRer3ccd5h7YkSHA1x1m/RjSORXIWN/jlih3WwyB/tbbtSqpq9JivJZFLrM2MxiDD+mve31/GeJSZ7V/dymOvzwYV/pH4845HfRWKAtMg+cvwpS2TUaDuPBBYFuD7WCCXThCP4CPCyvM7WSIADlEwz+UI9vgdej7y0AIYy2CDgDMuOqGAKlq2QRTDQiaM/yNcGJjXJNGApWuSf9VEjnEIyCKDQHXNx1/grjEQt3cGtShVV4yaonwAXUjU+AYrxWKCVduZ2SCDuYTs6D55DHOMrFf4jbyEiuHc2Ew3gYLMQjSJhpDDSQ/NQN/EpugWUP+kxIRjv0oZZ5jnRDG2G/q748U3rGTcYjjHNxurpUiAtZQozBnX2vyTdrFigmvybylBCj56SWa52nj5d/19ZKfdQ/+dcpK5tsRyWWedJa/5OtLnU74O6nZXd3kE49zr3XuknGmGJL7YDbuR3DT/t1V1tY0vWvEowNLgV8b75r+8TngX47Yk7IL//reKvyjciOEufSuI7zTJPzPvPrqKRrU9RO85dBMPNXrWAiU6ZGwReJDUT4gBuCd8NZdo0UsAGGKmhGRKY4h+hh5E9CmPcVgAc/mATneA16wnfiPnIFGokATRknYcDhzYaGkAOZkkBzhYMCQA3ohdbAZPqKW8L65zT+CT5CU5gGZiIXU74eaAavw040iNuGczASROjPyO0Fh+E5HwW1SbjE06dSfdoYTsAuOAcj8CulLhi4X5UDnNM4TH2NkugWFKGbrRH2L4xzua62IrE9T8Sm3FhaaE4SK0iF/0r8QO1l3ygleH7TI/WJkiUqx1mi5ehP9FdiCy1DctsMfLC4OYVHLnmg8K2rXs+P2yS6flKmdjbRPbEN3LeaSxNitBCfmCbngpb5TjHm++1WRxYvHzrcKUUk6aJjcmjbuk39nynjCCfs823pqidWFyfJ931eiO/7PQ8Z9T+WtwtB8+u+lgtQv/bZeva4yQEbJQ+9Zbg2ZxlsoV5OmjGGavnPogogmEEd2Awd6T/+E8EUcBHvpzWkHZoIM5leYa+KwRD4nSesPw4RSnA7qGS6xDEqe8Nc1N7gADOsFlaRZ5zK6jiYemWCmR/HVTAFnMB9h7/mVzJvthf6o+5wFG5zbvgdvqPd8ZdonAOzfVJhA2yEC5wZKmGnIJG/4UN2lTHcAFxoFXosa7ARNzXspff4q2IW/IDykVPtYh5hfsWtQtl6pFjG/xF5HJbBYnitV5LqPseYWu7S74m9/LaLh8XheLkVO53aU9Vl/hj/TX0pnpXX8Rv0CkO7qGB9E620FXhKtETHGelZmxdkG5fouhV5oFlda6nVv98jw037UpnTi4Xmls/7OS0tAlYohfqm8MTgKY59hj/i6pqNO+sPTAn92FNL3GYrC+syf3ZQiulTLlxMl4eTL8QNtv3Exz0Sb3NPjvjXnxdWRe3LqRKMqnlWE/1qn/P+2NFJc0tt5rrRG+bbvwCENGgc1pnGM8Ze0TQ8Ex1k95iR0cbDNbiMJZChhLREBKcz/RHZS4NP4AxHGZHx/GK8AU4ZgfVKifm0Xfi0GAuh0F5oSe5KKyVgHmop06BRtAMXiuwQwV3BvZCFsdoPcazXlqKWnBVWQhn9CIeixcyn+bL6g2EPVFEblMEcrhu24jCiwnx21OnQHr+RguASPirWozvM+ZbWMIYW4zSu2NxLvyCexUfNB4R42okfC0W4A+5JQrhy60m4wrm0x/zU4InWSrScOE0e20pTqbFK/QrPUg4Iw2Q33YvnGXdSKrTlT1o3BM12fW+7Kd5OcXA+/KGAiz5da1QpURZzWpVU3VIhlTnjhKMWc7eGtI1rt9pJ+y4kwuepeZrUSCsiCeHHa3cm+/RMuY/1hc+jWo1dHyun5bXo5KzqlrvmV8lGesrne6l+u/UBy2WbFMkdDivRVM+p2Ep9m7OW/zFXl5De/zL6FpvwzbD+qKvlwfCzcr02va1pjgv8CsU5JwvtYDxweDZjaLj/QTIGCLSnT9EreCl4OVGZXh2EL7DItGg4GYUC0QsF2OrKbOXXQQlnYloUyc/GkYhnPj+I7WWAQ6hECGMddBE/BmcI3ZjPH8+cewi8RzbSY4zbxvQXxudvCJhScYzcOohwPKRBD+qDM9Ehpm8WVt0NF8BNRaZRB+lvKAqvZx5vL3SHutAX3xM1iEGjhWlkpOhWddjErYCX+IlUoL02vIS6+kj+Ot4o+MJo3Brexx6y3fIpzCFr1DR+sdMuD4TuvIl+KWQqy5Rv5JNosqEH942xmLaFi+IQ8gE5Sg+Zf/EZaMgw1xCiIiNxO1TbViBP1hsZpmtfBOVTm+kuf0rzceaQjeHrXY/47dJ5U1vbOWM/vVjE5nLxhUEIeYMlPlJAlmitemCcvZUcLlyCDJvd6CQ3fSeSKkcT7N9c99WNTaLHUFJ6Iv0bwZxhUPc4/Zpe7KEF7tKqGfyklXVcjgZtJ3acmLLXxx5+3zTZ1/5P9/tpixq/zOjCR9oLU36WXjTr7+wWtdexR3wwKx7lMj3xw9MYV9m2HBrFJrHN5G+oG7IzfnwYBRjy0Bnsx3ToKm6FaqLaonfdvSt/BeychelVQ87K9I1jHIYz4hToiOcLPzKWunJZGIT7jJNsSGL+7AEeQn2RDkvIGHQJrcUAp//qqAWoC9WYt19OfHF99BXL12d1dLgK5cQHXkEK3Y4W4NkIwTSmVvUgAdvEEGiMmvN3cXc+ROLZBDoG4tBp5T2ToKyAMeoSLoVbRyXIRw4ogWBSXT8NE/EO+e+0v61Y7QvJpCVJx/u1lXKFWAM9EGNpb7EtdcIN+ic8Qe/R3loPPlCorkmC1b2LsVlbCaPXhVbM3SebGxKLksVVSgf5eWAJ8kFpUh3DDmWVpBk0lRNr2U5THp/TV8Bn/Hq6wTRYPqaPMfc05Imd0UpcVxiGBsgHSY4lh7SvUWYpkrLdDm6yHOXZYdztO8fYyDLfOi66t2u18azRTxi0v3e1JbNjyo4lgL2oSa2EM45jyuygh+K6qOkpM3w6a82s9X3bxP8UsbHak7f2PCQuShv4CsqFLUHHZXPjF9aW3D7jT+K6aV1gHuOHZy+AMH09YSICx0k+2gDvCV4fxcQGHsFijIBCGqmNHOhXtr/XR3FQDqcpYbz4cBz+CZYKXp/m9VgL0WxeZP7qF2rHq0kwK2FmKiZABnlK7KxmCZmOPkQ7kHde4FhdK7KwOtWgiBxCPdBt6u2/iHF1CBYSwubOX8kO1BRHcN7nHj6M71toJ/P2y+ElJ5F2XGMVw3Hm3rbCOKFK2YKywKSso9eILCH4iCnoVtiDQ7VqMA41lQ/SuUq4osGn8C140K8ybxiEusAA0Y/e4lZxNtiHH0IRfEYeGEVagZ3GTdxOyyI8FC6RA4z3SvF9I+XOwK/ySG6N8aa8DKJkX+yDt/CDlSW4AddbfcpPkvcKG+CONAziyChabszDZuWS9oc4no9G59BYKpH+4jk83Fofz3CW2hoZ9pkPcB7DI60YD3Jxhtn6HP6lJ85xXv7W+IZvZa9pmVe/y5y4Wh3NQ2y/+v2shcktWx0UK84VjZpQtCnIZF7izD38bLA54oje0LRViBT31/nBQe0LAvY686VSrYbjufG/mqvFnseheXQxOeUeLwam3vGbzkdydcSFM0dCNltHCaxsvZ+aEEdYH4xm6zsfHZO8np2w/ES4gL3MnMQxKAZV+njziJE1CEzMqwcD4VLYX/xMXj4Re7dHj5mfZx2Mk/FFcgt762vsHUUuECfjqDqZim4izPLV/6pzGK6wHhcEH+MPUAP0QPdyixhbS+ER49wHRDoTPcYlAmJdmbB+akDV2OdukMOvw4X8axuGLLaViNoaeik10Xtw3HCQDEEnVcK+WwDzaal4lGqEEBQstaL+hmVCMtRkU8Io9ESKlFJRK/ATPieV6iKNwGXSnVVfSCYYS7EfV0eJ44r0aByHAnEuuolt0odyIfFBDQ1f00jDfPodTBd6QX3cTHgsFaA7+JxUTm8JOfJMvIg+Z3QeJoMUf1xLXGjcyO+Vh1GKKZ6GbupL0WOtGLq5D+jfCofVuUq++JArwhstTeUsk1OcZX6oh0kOrT5OdmTIyZ45feTqj00/y6q1jvqnIa7FWGuJq2+3rPyOvhbXj/bFx1dnmiIum6wmGzm9OTe/fd3xyaOcP+h2+XvPDf2q/D2ZIpcYA/g83MiQK1q0H8kE/17BWf9p/fS01WfybRjPt6QVUv1mATY/cSI5z/tP94Es0evDvazY5TfexWb3dyMUAcc5b867PRzOeWWM9Z/rsAYyDf/IY8iAw8TLYSkZhKrBAgp/ZQkcgESOY59uMF1qht6n/9AxDHVxOvGe0HEcgFJRGasZwSjz/ioUSSjjbi12o5tsPeCvrMAmy1hWX4YEkoh4PIJ4fZ2ZdeDayDuH+jE9FJkvn8l08kPm5pYxPqYY0thcoEsLSTmyMuY7QynUhs+RRW0DOcB6HnFwsTJiZxQCM2EFv1Y8y/htzeukE5fJ2D4B0TASVuKmcmM8HLobutEHUg/MQTTOgtswlidKV+KGYslNZ4v5zONZ6SwYBvfo+9I+uAXxkj9dRxrQaOhNGsEvqDNxKdtwEt6hJPBW2h59hnZjqm3CS9FBfSSUGI7rh4VU6Q2+h57IC9Ed63M+zlTJLxLO6w5xrbqLv4ElwxDpWYtJCYu0PpYVwiBlvjQz4RU3R21fS+ReG1uqibY5TTfqcwIOG7sKWdI1+ecPa8mj3QP9A6z+jlBloH5bbhZ4gs+61NcSceRAw930vh7S7Yvd40L3a8+aJ/HT+Sj9d0OL4CTXVv2Ia7d4zFGp/Hu5mhBw470T0kFSmTZNVjoEu56r6YYMbvaMGnCP8aOC9/lCrNSRennojOuyuz6KzYkEvA8b2jLH5PVBPvg+W6lPHF5+vIrVAPzY/owHUoQawHX6Dx687prjDUy3BjOfn4/sxKs/JsbJb6gHsbI9IlnXTEMd2P5+f+0/FEyEgyhoh0PQU3hogr9UkmPHtRJvn72KY9EM0t7s7Y8qq+RBDdmQMBIm0itoBq7ObooB0Bh+glZCkXwAJ8AxcQW5gtyM/2SIZP4qF+1VImEsvM8vw3vpZp4RDptgDKRxZ4VV7Li/0nb4S1xGEXzGKG4Md9Fj6RDrmzzj8ENJYef+AjLRdnSFuyz54nz4jr+PLWQHkeA33AlWg5E+Ei4hBTmFamQhHsN69FJ8ApZAEOkmpaNsHGVoRTfxo/ls0HEGuYW6oAp1O9ps+cZ0hFcsE7lOMJFodJHk4bYrm6hRvmy8yO9RCB+ObtFxYd8n5cWuMoYZq4u9lSKxTugO4XtUFDPS8Idttfaz3qlFcMh2395KojiLBCvr+5TEnrcdd3U23VfHKs+Nv4nvKQv5IM3iBufUmuM4s9bL8+vQWHcHrbD7NXzmyx4hI2vEpzqcR4zlrVdri7Q5YiFuLbSwnHFW0vcMnxKzc5Qw0lkWc/n/+jzkQNLMat1dU2I+GmkPdvu10bS4nxy7DEuKU/Fgti4fkmuMrL7GP+glZIJjeDEqR5sYVx3+6jwFMI/1Lw124QSUg+qwnh3FupME/aERXwPioRdtiR+iBmwdrSxL4SbsY3kNeHoM7aXDmeQ1ZI5ehpWsw4xjvAViP3QSXWL5ir/mgipozfyVB17g4agQLrM68l9+vi+sIzwjI4zp1QD0i+R9vhrGuHKgPmztsiCPdsLnhVDWB8NQI6ZLn3AhspP5q0CplBxFP2qIdXA782RlKM9YHVbAFSGV9OebMx17BB9AHmygq/lOqBZg2g135e9LGHxQD6gD8eSVQWST6xWhgJwSmrF5YQhaDzthHOksVqGekMO61gxSplOoRWawb7mLbBaD0B1oK94mL4nbILM7MJgduwr5ygVoKvpEXs8m4EDsgo5sKqqCdJSgxrGjOoyr6U4FSUMhgQ6DEbiF8ExJpw5uq1rJz8UHiQeyhLW8x1JTfCKliPNQLVGks0OOGbugDHNP0UOshlHax4F/ao3sIyW34QGuSQc3qO07QvnT6FD66MvFu1IMr8vPpTNiD/UyitXcHFZPCidjrjodhp+SRqJsOd9/lVEICzAuF1+G7zKGSW4+j/LS6up5jk54QkBt+sa+WRba7fdMMi1R5nEFyy8FPUxz9YodXapvSxsRP89xSv0/Y5vn1w==\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_4babede\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f7028a26020>"
            ]
          },
          "execution_count": 12,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 2)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "7OEhpa-HLZJq",
        "outputId": "a27f6688-a121-4ca3-efe8-9f3d71bc37cd"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 4 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_530d40d\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" head\",\n",
              "\" detector\",\n",
              "\" feature\",\n",
              "\" for\",\n",
              "\" Trans\",\n",
              "\"former\",\n",
              "\"Lens\",\n",
              "\" allows\",\n",
              "\" users\",\n",
              "\" to\",\n",
              "\" check\",\n",
              "\" for\",\n",
              "\" various\",\n",
              "\" common\",\n",
              "\" heads\",\n",
              "\" automatically\",\n",
              "\",\",\n",
              "\" reducing\",\n",
              "\" the\",\n",
              "\" cost\",\n",
              "\" of\",\n",
              "\" discovery\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"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\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_530d40d\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f702b7cc3a0>"
            ]
          },
          "execution_count": 13,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 4)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "f4Eiua9pMLok"
      },
      "source": [
        "As we expected, L2H2 is doing a lot of previous token detection, but doesn't appear to be a sharp previous token detection head. L4H11, on the other hand, is pretty much perfect. In fact, the only place it seems to be putting any other attention is the very first token, where it pays attention to the BOS (*beginning-of-sentence*) token.\n",
        "\n",
        "Mechanistic interpretability is still a very new field, and we don't know the best ways to measure things yet. Ignoring attention paid to BOS allows us to solve problems like the above, but may also give us artifically high results for a head like L4H10, which doesn't appear to be doing much of anything, but does have a bit of previous token attention going on if you squint carefully.\n",
        "\n",
        "As such, the head detector supports both an `exclude_bos` and `exclude_current_token` argument, which ignores all BOS attention and all current token attention respectively. By default these are `False`, but this is a pretty arbitrary decision, so feel free to try things out! You don't need a good reason to change these arguments - pick whatever best helps you find out useful things!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "C42HUkb_NRad",
        "outputId": "3669bb7c-0d18-45ba-8d62-18162fb70b89"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"7b7b9063-076a-46c8-ab7a-82b3ff1ec76e\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"7b7b9063-076a-46c8-ab7a-82b3ff1ec76e\")) {                    Plotly.newPlot(                        \"7b7b9063-076a-46c8-ab7a-82b3ff1ec76e\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.11072563380002975,0.06217610463500023,0.08318743854761124,0.6219362020492554,0.31335216760635376,0.009239129722118378,0.12432026118040085,0.39387285709381104,0.1270543336868286,0.10435156524181366,0.0928037017583847,0.11137393116950989],[0.3620687425136566,0.2715803384780884,0.15287074446678162,0.16992124915122986,0.1374446600675583,0.08939207345247269,0.1046200841665268,0.1184455081820488,0.11431940644979477,0.08287395536899567,0.17697742581367493,0.07280709594488144],[0.2717510759830475,0.11410916596651077,0.7370071411132812,0.3372900187969208,0.442963570356369,0.4032770097255707,0.16718655824661255,0.18943332135677338,0.3533322811126709,0.43407705426216125,0.19844099879264832,0.1947302520275116],[0.024883843958377838,0.2147981822490692,0.518895149230957,0.7983013987541199,0.13656142354011536,0.12315608561038971,0.39323827624320984,0.7245805263519287,0.47648993134498596,0.32068249583244324,0.31928449869155884,0.3158501982688904],[0.4089745879173279,0.2923681139945984,0.09356193244457245,0.41554832458496094,0.29143640398979187,0.3694373369216919,0.23720358312129974,0.5116032958030701,0.1385640650987625,0.20659516751766205,0.10239365696907043,0.9999570250511169],[0.20577017962932587,0.0734705775976181,0.3327053487300873,0.14700551331043243,0.3363662362098694,0.043391697108745575,0.8785974979400635,0.4700332283973694,0.09325103461742401,0.07369309663772583,0.17477068305015564,0.20820800960063934],[0.33454352617263794,0.29545488953590393,0.07758066058158875,0.09444612264633179,0.1471666693687439,0.26756733655929565,0.20694714784622192,0.2077888399362564,0.5708193182945251,0.04593973234295845,0.1328779011964798,0.3419584631919861],[0.6497496962547302,0.103756383061409,0.17069365084171295,0.19664545357227325,0.16103407740592957,0.13670717179775238,0.10680953413248062,0.16964732110500336,0.3102462589740753,0.15131977200508118,0.0880156084895134,0.10507933050394058],[0.1903480887413025,0.12134813517332077,0.11293741315603256,0.07598625868558884,0.3678419888019562,0.2098838984966278,0.2191234976053238,0.5511329770088196,0.09223752468824387,0.11348974704742432,0.1605023890733719,0.06839644908905029],[0.13639304041862488,0.10622527450323105,0.08107800781726837,0.4466576874256134,0.07560527324676514,0.1375022530555725,0.0811062604188919,0.12407653033733368,0.1241082027554512,0.05919433385133743,0.3325606882572174,0.08007194101810455],[0.0845143273472786,0.06533591449260712,0.07811396569013596,0.09368076920509338,0.11339452117681503,0.1438310146331787,0.07224351167678833,0.10936052352190018,0.1107235923409462,0.3553868234157562,0.06057136505842209,0.41548994183540344],[0.12831847369670868,0.08271832019090652,0.07047650218009949,0.22901862859725952,0.11361213028430939,0.06964562088251114,0.05138615891337395,0.13071949779987335,0.22392329573631287,0.07566433399915695,0.15798157453536987,0.15286697447299957]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Previous Head Matches\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('7b7b9063-076a-46c8-ab7a-82b3ff1ec76e');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(model, prompt, \"previous_token_head\", exclude_bos=True, exclude_current_token=True)\n",
        "plot_head_detection_scores(head_scores, title=\"Previous Head Matches\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oiWQjv9UNerH"
      },
      "source": [
        "Now we have a lot more detection, including L0H3 and L5H6 which were unremarkable before. Let's check them out!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "cCsB8fD8oH5i",
        "outputId": "e1ebdc6d-07a6-446d-91de-a5b197e999b5"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 5 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_ce9fde\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" head\",\n",
              "\" detector\",\n",
              "\" feature\",\n",
              "\" for\",\n",
              "\" Trans\",\n",
              "\"former\",\n",
              "\"Lens\",\n",
              "\" allows\",\n",
              "\" users\",\n",
              "\" to\",\n",
              "\" check\",\n",
              "\" for\",\n",
              "\" various\",\n",
              "\" common\",\n",
              "\" heads\",\n",
              "\" automatically\",\n",
              "\",\",\n",
              "\" reducing\",\n",
              "\" the\",\n",
              "\" cost\",\n",
              "\" of\",\n",
              "\" discovery\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"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\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_ce9fde\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f702b7cefb0>"
            ]
          },
          "execution_count": 15,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 5)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "wMbU3X5OoNO3",
        "outputId": "659cc27d-5fcc-4523-c767-500e1cf9e2ae"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 0 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_e23936\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" head\",\n",
              "\" detector\",\n",
              "\" feature\",\n",
              "\" for\",\n",
              "\" Trans\",\n",
              "\"former\",\n",
              "\"Lens\",\n",
              "\" allows\",\n",
              "\" users\",\n",
              "\" to\",\n",
              "\" check\",\n",
              "\" for\",\n",
              "\" various\",\n",
              "\" common\",\n",
              "\" heads\",\n",
              "\" automatically\",\n",
              "\",\",\n",
              "\" reducing\",\n",
              "\" the\",\n",
              "\" cost\",\n",
              "\" of\",\n",
              "\" discovery\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"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\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_e23936\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f702b7cc820>"
            ]
          },
          "execution_count": 16,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 0)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Gtxc-sUlN0lo"
      },
      "source": [
        "Here, we see some interesting results. L5H6 does very little, but happens to react quite strongly to the first token of \"Trans|former\". (Capital letters? Current word detection? We don't know)\n",
        "\n",
        "L0H3 reacts almost entirely to the current token, but what little it does outside of this pays attention to the previous token. Again, it seems to be caring about the first token of \"Trans|former\".\n",
        "\n",
        "In order to more fully automate these heads, we'll need to discover more principled ways of expressing these scores. For now, you can see how while scores may be misleading, different scores lead us to interesting results."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Dzvf8UsiwR18"
      },
      "source": [
        "## Using Head Detector for Custom Heads\n",
        "\n",
        "These heads are great, but sometimes there are more than three things going on in Transformers. [citation needed] As a result, we may want to use our head detector for things that aren't pre-included in TransformerLens. Fortunately, the head detector provides support for this, via **detection patterns**.\n",
        "\n",
        "\n",
        "A detection pattern is simply a matrix of the same size as our attention pattern, which specifies the attention pattern exhibited by the kind of head we're looking for.\n",
        "\n",
        "There are two error measures available for quantifying the match between the detection pattern and the actual attention pattern. You can choose it by passing the right value to the `error_measure` argument.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "aM8NGXj7wRs_"
      },
      "source": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OFLBWOw3wUWb"
      },
      "source": [
        "\n",
        "### 1. `\"mul\"` (default) multiplies both tensors element-wise and divides the sum of the result by the sum of the attention pattern.\n",
        "\n",
        "Typically, the detection pattern should in this case contain only ones and zeros, which allows a straightforward interpretation of the score: how big fraction of this head's attention is allocated to these specific query-key pairs? Using values other than 0 or 1 is not prohibited but will raise a warning (which can be disabled, of course).\n",
        "\n",
        "<br>\n",
        "\n",
        "$$\n",
        "\\begin{pmatrix}\n",
        "1 & 0 & 0 & 0 \\\\\n",
        "0.5 & 0.5 & 0 & 0 \\\\\n",
        "0.2 & 0.3 & 0.5 & 0 \\\\\n",
        "0.1 & 0.15 & 0.5 & 0.25\n",
        "\\end{pmatrix}\n",
        "\\odot\n",
        "\\begin{pmatrix}\n",
        "0 & 0 & 0 & 0 \\\\\n",
        "1 & 0 & 0 & 0 \\\\\n",
        "0 & 1 & 0 & 0 \\\\\n",
        "0 & 0 & 1 & 0\n",
        "\\end{pmatrix}\n",
        "=\n",
        "\\begin{pmatrix}\n",
        "0 & 0 & 0 & 0 \\\\\n",
        "0.5 & 0 & 0 & 0 \\\\\n",
        "0 & 0.3 & 0 & 0 \\\\\n",
        "0 & 0 & 0.5 & 0\n",
        "\\end{pmatrix}\n",
        "$$\n",
        "\n",
        "<br>\n",
        "\n",
        "0.5, 0.3, and 0.5 all get multiplied by 1, so they get kept. All the others go to 0 and are removed. (Note: You can use values other than 0 or 1 when creating your own heads)\n",
        "\n",
        "Our total score would then be 1.3 / 4, or 0.325. If we ignore bos and current token, it would be 0.8 / 0.95 instead, or ~0.842. (This is a large difference, but the difference generally gets smaller as the matrices get bigger)\n",
        "\n",
        "This is how the head detector works under the hood - each existing head just has its own detection pattern. Thus, we can pass in our own detection pattern using the `detection_pattern` argument."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Mewy1K9fOmOk"
      },
      "source": [
        "\n",
        "### 2. `\"abs\"` calculates the mean element-wise absolute difference between the detection pattern and the actual attention pattern.\n",
        "\n",
        "The \"raw result\" ranges from 0 to 2 where lower score corresponds to greater accuracy. Subtracting it from 1 maps that range to (-1, 1) interval, with 1 being perfect match and -1 perfect mismatch.\n",
        "\n",
        "We take the attention pattern and compute its absolute element-wise difference with our detection pattern. Since every number in any of the two patterns has a value between -1 and 1, the maximum absolute difference of any pair is 2 and the minimum is 0:\n",
        "\n",
        "$$|-1-1|=|1-(-1)|=2$$\n",
        "\n",
        "$$|x-x|=0$$\n",
        "\n",
        "That number tells us how much our expectation and the real attention pattern diverge, i.e., the error.\n",
        "\n",
        "$$\n",
        "M_{diff}=\n",
        "\\left|\n",
        "\\begin{pmatrix}\n",
        "1 & 0 & 0 & 0\n",
        "\\\\\n",
        "0.5 & 0.5 & 0 & 0 \n",
        "\\\\\n",
        "0.2 & 0.3 & 0.5 & 0 \n",
        "\\\\\n",
        "0.1 & 0.15 & 0.5 & 0.25 \n",
        "\\end{pmatrix}\n",
        "-\n",
        "\\begin{pmatrix}\n",
        "0 & 0 & 0 & 0\n",
        "\\\\\n",
        "1 & 0 & 0 & 0 \n",
        "\\\\\n",
        "0 & 1 & 0 & 0 \n",
        "\\\\\n",
        "0 & 0 & 1 & 0 \n",
        "\\end{pmatrix}\n",
        "\\right|\n",
        "=\n",
        "\\begin{pmatrix}\n",
        "1 & 0 & 0 & 0\n",
        "\\\\\n",
        "0.5 & 0.5 & 0 & 0 \n",
        "\\\\\n",
        "0.2 & 0.7 & 0.5 & 0\n",
        "\\\\\n",
        "0.1 & 0.15 & 0.5 & 0.25 \n",
        "\\end{pmatrix}\n",
        "$$\n",
        "\n",
        "\n",
        "We take the mean and multiply it by the number of rows.\n",
        "\n",
        "We subtract the result from 1 in order to map the (0, 2) interval where lower is better to the (-1, 1) interval where higher is better.\n",
        "\n",
        "$$1 - \\text{n_rows} \\times \\text{mean}(M_{diff}) = 1 - 4 \\times 0.275 = 1 - 1.1 = -.1$$\n",
        "\n",
        "Our final score would then be -1. If we ignore `BOS` and current token, it would be 0.6625. (This is a large difference, but the difference generally gets smaller as the matrices get bigger.)\n",
        "\n",
        "This is how the head detector works under the hood - each existing head just has its own detection pattern. Thus, we can pass in our own detection pattern using the `detection_pattern` argument.\n",
        "\n",
        "I'm curious what's going on with this L0H3 result, where we mostly focus on the current token but occasionally focus on the \"Trans\" token in \"Trans|former\". Let's make a **current word head** detection pattern, which returns 1 for previous tokens that are part of the current word being looked at, and 0 for everything else."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "AS5yRsZgwtAl"
      },
      "source": [
        "### **Which one should you use?** \n",
        "\n",
        "`\"abs\"` is likely better for quick or exploratory investigations. For precise examinations where you're trying to reproduce as much functionality as possible or really test your understanding of the attention head, you probably want to switch to `\"abs\"`. \n",
        "\n",
        "The advantage of `\"abs\"` is that you can make more precise predictions, and have that measured in the score. You can predict, for instance, 0.2 attention to X, and 0.8 attention to Y, and your score will be better if your prediction is closer. The \"mul\" metric does not allow this, you'll get the same score if attention is 0.2, 0.8 or 0.5, 0.5 or 0.8, 0.2."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KjeBZ9XBxsjb"
      },
      "source": [
        "Below we show how different scores these two measures can give on the same prompt. After that, we will proceed with using `\"abs\"` and will get back to `\"mul\"` at the end of the notebook."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "eknvQfWmRr74",
        "outputId": "cf428f24-dd7d-4760-ed34-986f588c1411"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "23 ['<|endoftext|>', 'The', ' following', ' lex', 'ical', ' sequence', ' has', ' been', ' optim', 'ised', ' for', ' the', ' maxim', 'isation', ' of', ' lo', 'qu', 'aciously', ' multit', 'oken', ' letter', ' combinations', '.']\n"
          ]
        },
        {
          "data": {
            "text/plain": [
              "torch.Size([23, 23])"
            ]
          },
          "execution_count": 17,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "prompt = \"The following lexical sequence has been optimised for the maximisation of loquaciously multitoken letter combinations.\"\n",
        "tokens = model.to_str_tokens(prompt)\n",
        "print(len(tokens), tokens)\n",
        "detection_pattern = []\n",
        "for i in range(2):\n",
        "  detection_pattern.append([0 for t in tokens]) # Ignore BOS token and first token.\n",
        "for i in range(2, len(tokens)):\n",
        "    current_token = i\n",
        "    previous_tokens_in_word = 0\n",
        "    while not tokens[current_token].startswith(' '): # If the current token does not start with a space (and is not the first token) it's part of a word.\n",
        "      previous_tokens_in_word += 1\n",
        "      current_token -= 1\n",
        "    # Hacky code that adds in some 1's where needed, and fills the rest of the row with 0's.\n",
        "    detection_pattern.append([0 for j in range(i - previous_tokens_in_word)] + [1 for j in range(previous_tokens_in_word)] + [0 for j in range(i+1, len(tokens)+1)])\n",
        "detection_pattern = torch.as_tensor(detection_pattern).to(device)\n",
        "detection_pattern.shape"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "id": "rOh5aUu80Ols"
      },
      "outputs": [],
      "source": [
        "_, cache = model.run_with_cache(prompt)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cBbW960Tw7hI"
      },
      "source": [
        "`\"mul\"`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "bm9z5sR4Yu3A",
        "outputId": "b26da44a-4dcf-4489-a558-4801a7fcbcc4"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"5850f3f0-6af3-420e-be0c-d92830dacf5b\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"5850f3f0-6af3-420e-be0c-d92830dacf5b\")) {                    Plotly.newPlot(                        \"5850f3f0-6af3-420e-be0c-d92830dacf5b\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.053881045430898666,0.009134032763540745,0.011518196202814579,0.6768534183502197,0.3375774919986725,0.09022346884012222,0.07635483890771866,0.19938454031944275,0.034454166889190674,0.019474325701594353,0.01446285005658865,0.023821262642741203],[0.16714942455291748,0.04102460667490959,0.03820975497364998,0.022736143320798874,0.030868755653500557,0.008089723065495491,0.12618282437324524,0.01789647527039051,0.015210181474685669,0.009790991432964802,0.05470702424645424,0.018710626289248466],[0.059849586337804794,0.008347772061824799,0.27221545577049255,0.0778457522392273,0.1877870410680771,0.03770679235458374,0.010260149836540222,0.0472760871052742,0.05349385365843773,0.12129901349544525,0.04962966591119766,0.017455337569117546],[0.0037993737496435642,0.016268940642476082,0.0915832668542862,0.18210652470588684,0.0015062199672684073,0.00981654692441225,0.1720503270626068,0.11681348085403442,0.025235751643776894,0.05374597758054733,0.01928246021270752,0.10852731019258499],[0.08680612593889236,0.028675738722085953,0.0056416648440063,0.06456581503152847,0.014243798330426216,0.05771105736494064,0.02722332999110222,0.056518953293561935,0.0058715371415019035,0.02125389128923416,0.002347399480640888,0.31819039583206177],[0.013000339269638062,0.00025018915766850114,0.054959993809461594,0.0206269770860672,0.022157780826091766,0.0015348049346357584,0.04113982245326042,0.05437175929546356,0.011865342035889626,0.0036532743833959103,0.04464048147201538,0.006868354976177216],[0.01809140481054783,0.024348270148038864,0.0018828512402251363,0.004089162684977055,0.014574176631867886,0.015343616716563702,0.0062201060354709625,0.030665190890431404,0.12165740877389908,0.003758937818929553,0.004287956282496452,0.022381989285349846],[0.017522279173135757,0.007366911042481661,0.000693025067448616,0.01813414879143238,0.012028343044221401,0.009337023831903934,0.0054315607994794846,0.0031645228154957294,0.039908889681100845,0.010862188413739204,0.0013000426115468144,0.003656611777842045],[0.0028315160889178514,0.0011623245663940907,0.012629282660782337,0.006796164903789759,0.04020766168832779,0.01149373222142458,0.00522964121773839,0.027098504826426506,0.019022837281227112,0.020649434998631477,0.01092604547739029,0.009827710688114166],[0.019487200304865837,0.001875428482890129,0.009590012952685356,0.039891842752695084,0.002318682847544551,0.0028682472184300423,0.004153797868639231,0.004250946454703808,0.007975748740136623,0.004105094820261002,0.015891406685113907,0.0014007101999595761],[0.009462091140449047,0.007500508334487677,0.004893372766673565,0.006390577182173729,0.013528706505894661,0.006935104262083769,0.007706491742283106,0.010914715938270092,0.003413242055103183,0.04738344997167587,0.011234554462134838,0.0068846591748297215],[0.01941857300698757,0.008681506849825382,0.008542266674339771,0.01380442176014185,0.010920328088104725,0.002787489676848054,0.007071709260344505,0.007292057853192091,0.04359397292137146,0.006503289565443993,0.01427435502409935,0.01856648363173008]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Current Word Head Matches (mul)\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('5850f3f0-6af3-420e-be0c-d92830dacf5b');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(\n",
        "    model, \n",
        "    prompt, \n",
        "    detection_pattern=detection_pattern, \n",
        "    exclude_bos=False, \n",
        "    exclude_current_token=True, \n",
        "    error_measure=\"mul\"\n",
        ")\n",
        "plot_head_detection_scores(head_scores, title=\"Current Word Head Matches (mul)\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "MgglfsyzxGFe"
      },
      "source": [
        "`\"abs\"`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "oVzeaGEhxKrq",
        "outputId": "94dbc3b4-0b84-4c1f-be51-0427c96d0076"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"4f8b992d-40e9-4330-a88a-855d63213801\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"4f8b992d-40e9-4330-a88a-855d63213801\")) {                    Plotly.newPlot(                        \"4f8b992d-40e9-4330-a88a-855d63213801\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[-0.16099999845027924,0.6179999709129333,-0.24199999868869781,0.7519999742507935,0.5019999742507935,0.5270000100135803,-0.1080000028014183,0.16200000047683716,-0.12399999797344208,-0.22300000488758087,-0.06700000166893005,-0.1889999955892563],[0.06700000166893005,-0.12600000202655792,-0.1289999932050705,-0.18000000715255737,-0.16599999368190765,-0.18400000035762787,-0.03500000014901161,-0.2240000069141388,-0.22200000286102295,-0.2549999952316284,-0.03200000151991844,0.41999998688697815],[-0.1080000028014183,-0.24899999797344208,0.2590000033378601,-0.07199999690055847,0.09399999678134918,-0.11400000005960464,-0.19499999284744263,-0.0689999982714653,-0.11999999731779099,0.004000000189989805,-0.07500000298023224,-0.2070000022649765],[-0.23199999332427979,-0.22300000488758087,-0.03999999910593033,0.08500000089406967,-0.2930000126361847,-0.25600001215934753,0.0949999988079071,0.009999999776482582,-0.15000000596046448,-0.14900000393390656,-0.11900000274181366,-0.05000000074505806],[-0.10100000351667404,-0.1899999976158142,-0.26899999380111694,-0.12800000607967377,-0.2370000034570694,-0.1289999932050705,-0.21699999272823334,0.2750000059604645,-0.2750000059604645,-0.2329999953508377,-0.28200000524520874,0.30399999022483826],[-0.2630000114440918,-0.3019999861717224,-0.18400000035762787,-0.23600000143051147,-0.2150000035762787,-0.2840000092983246,-0.19699999690055847,-0.17000000178813934,-0.2529999911785126,-0.2879999876022339,-0.1599999964237213,-0.19699999690055847],[-0.23800000548362732,-0.24199999868869781,-0.28600001335144043,-0.2840000092983246,-0.19499999284744263,-0.22200000286102295,-0.22100000083446503,-0.2029999941587448,-0.04600000008940697,-0.2919999957084656,-0.2879999876022339,-0.2150000035762787],[-0.24500000476837158,-0.25,-0.3009999990463257,-0.23499999940395355,-0.27399998903274536,-0.2680000066757202,-0.2770000100135803,-0.2919999957084656,-0.19900000095367432,-0.2590000033378601,-0.296999990940094,-0.2930000126361847],[-0.2529999911785126,-0.29600000381469727,-0.23499999940395355,-0.2669999897480011,-0.1889999955892563,-0.25099998712539673,-0.2759999930858612,-0.2070000022649765,-0.1940000057220459,-0.2199999988079071,-0.2290000021457672,-0.2709999978542328],[-0.22100000083446503,-0.2919999957084656,-0.2630000114440918,-0.16699999570846558,-0.29100000858306885,-0.2709999978542328,-0.2879999876022339,-0.28299999237060547,-0.27000001072883606,-0.28700000047683716,-0.24400000274181366,-0.29899999499320984],[-0.2669999897480011,-0.27900001406669617,-0.28200000524520874,-0.2630000114440918,-0.23499999940395355,-0.26899999380111694,-0.2709999978542328,-0.24799999594688416,-0.28700000047683716,-0.15600000321865082,-0.2720000147819519,-0.24799999594688416],[-0.14800000190734863,-0.25600001215934753,-0.26899999380111694,-0.24400000274181366,-0.2370000034570694,-0.2720000147819519,-0.27799999713897705,-0.257999986410141,-0.06599999964237213,-0.2759999930858612,-0.20900000631809235,-0.22599999606609344]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Current Word Head Matches (abs)\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('4f8b992d-40e9-4330-a88a-855d63213801');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(\n",
        "    model, \n",
        "    prompt, \n",
        "    detection_pattern=detection_pattern, \n",
        "    exclude_bos=False, \n",
        "    exclude_current_token=True, \n",
        "    error_measure=\"abs\"\n",
        ")\n",
        "plot_head_detection_scores(head_scores, title=\"Current Word Head Matches (abs)\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "t8AnWKW2Y9Jj"
      },
      "source": [
        "75% match for L0H3 - only 16% for L5H6. Let's check them out with our new sequence!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "11l4x8H0ZEEp",
        "outputId": "71e275d8-b882-4d95-a077-1b6390552e31"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 5 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_387b6e8\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" following\",\n",
              "\" lex\",\n",
              "\"ical\",\n",
              "\" sequence\",\n",
              "\" has\",\n",
              "\" been\",\n",
              "\" optim\",\n",
              "\"ised\",\n",
              "\" for\",\n",
              "\" the\",\n",
              "\" maxim\",\n",
              "\"isation\",\n",
              "\" of\",\n",
              "\" lo\",\n",
              "\"qu\",\n",
              "\"aciously\",\n",
              "\" multit\",\n",
              "\"oken\",\n",
              "\" letter\",\n",
              "\" combinations\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"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\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_387b6e8\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f7028a79990>"
            ]
          },
          "execution_count": 21,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 5)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 22,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 339
        },
        "id": "d4bTwsAgYljL",
        "outputId": "d424ea36-af30-41cd-b7d0-3f7e8c3c53b9"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Layer 0 Attention Heads:\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "\n",
              "        <script>var AttentionMulti;AttentionMulti=(()=>{\"use strict\";var St={143:(x,B,te)=>{te.d(B,{default:()=>mn});function P(){}const me=e=>e;function jt(e,t){for(const n in t)e[n]=t[n];return e}function Mt(e){return e&&typeof e==\"object\"&&typeof e.then==\"function\"}function En(e,t,n,i,o){e.__svelte_meta={loc:{file:t,line:n,column:i,char:o}}}function Ge(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(Ge)}function fe(e){return typeof e==\"function\"}function je(e,t){return e!=e?t==t:e!==t||e&&typeof e==\"object\"||typeof e==\"function\"}function Sn(e,t){return e!=e?t==t:e!==t}function Ke(e){return Object.keys(e).length===0}function jn(e,t){if(e!=null&&typeof e.subscribe!=\"function\")throw new Error(`'${t}' is not a store with a 'subscribe' method`)}function Qe(e,...t){if(e==null)return P;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Mn(e){let t;return Qe(e,n=>t=n)(),t}function An(e,t,n){e.$$.on_destroy.push(Qe(t,n))}function At(e,t,n,i){if(e){const o=Me(e,t,n,i);return e[0](o)}}function Me(e,t,n,i){return e[1]&&i?jt(n.ctx.slice(),e[1](i(t))):n.ctx}function Ze(e,t,n,i){if(e[2]&&i){const o=e[2](i(n));if(t.dirty===void 0)return o;if(typeof o==\"object\"){const l=[],s=Math.max(t.dirty.length,o.length);for(let r=0;r<s;r+=1)l[r]=t.dirty[r]|o[r];return l}return t.dirty|o}return t.dirty}function Ct(e,t,n,i,o,l,s){const r=Ze(t,i,o,l);if(r){const f=Me(t,n,i,s);e.p(f,r)}}function Cn(e,t,n,i,o,l,s,r){const f=s(o)|Ze(t,i,o,l);if(f){const a=Me(t,n,i,r);e.p(a,f)}}function Dn(e){const t={};for(const n in e)n[0]!==\"$\"&&(t[n]=e[n]);return t}function On(e,t){const n={};t=new Set(t);for(const i in e)!t.has(i)&&i[0]!==\"$\"&&(n[i]=e[i]);return n}function Tn(e){const t={};for(const n in e)t[n]=!0;return t}function Ln(e){let t=!1;return function(...n){t||(t=!0,e.call(this,...n))}}function Nn(e){return e==null?\"\":e}function Pn(e,t,n=t){return e.set(n),t}const Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function Rn(e){return e&&fe(e.destroy)?e.destroy:P}const Bn=typeof window!=\"undefined\";let ae=null,ge=null;function Hn(e){ae=e}function xn(e){ge=e}const K=new Set;function $e(e){K.forEach(t=>{t.c(e)||(K.delete(t),t.f())}),K.size!==0&&ge($e)}function zn(){K.clear()}function ve(e){let t;return K.size===0&&ge($e),{promise:new Promise(n=>{K.add(t={c:e,f:n})}),abort(){K.delete(t)}}}function E(e,t){e.appendChild(t)}function C(e,t,n){e.insertBefore(t,n||null)}function j(e){e.parentNode.removeChild(e)}function et(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function F(e){return document.createElement(e)}function In(e,t){return document.createElement(e,{is:t})}function Vn(e,t){const n={};for(const i in e)Dt(e,i)&&t.indexOf(i)===-1&&(n[i]=e[i]);return n}function Ot(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function R(e){return document.createTextNode(e)}function T(){return R(\" \")}function tt(){return R(\"\")}function z(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function Wn(e){return function(t){return t.preventDefault(),e.call(this,t)}}function Yn(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Un(e){return function(t){t.target===this&&e.call(this,t)}}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Jn(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const i in t)t[i]==null?e.removeAttribute(i):i===\"style\"?e.style.cssText=t[i]:i===\"__value\"?e.value=e[i]=t[i]:n[i]&&n[i].set?e[i]=t[i]:y(e,i,t[i])}function Xn(e,t){for(const n in t)y(e,n,t[n])}function Gn(e,t,n){t in e?e[t]=n:y(e,t,n)}function Kn(e,t,n){e.setAttributeNS(\"http://www.w3.org/1999/xlink\",t,n)}function Qn(e,t,n){const i=new Set;for(let o=0;o<e.length;o+=1)e[o].checked&&i.add(e[o].__value);return n||i.delete(t),Array.from(i)}function Zn(e){return e===\"\"?null:+e}function $n(e){const t=[];for(let n=0;n<e.length;n+=1)t.push({start:e.start(n),end:e.end(n)});return t}function Tt(e){return Array.from(e.childNodes)}function ei(e,t,n,i){for(let o=0;o<e.length;o+=1){const l=e[o];if(l.nodeName===t){let s=0;const r=[];for(;s<l.attributes.length;){const f=l.attributes[s++];n[f.name]||r.push(f.name)}for(let f=0;f<r.length;f++)l.removeAttribute(r[f]);return e.splice(o,1)[0]}}return i?Ot(t):F(t)}function Lt(e,t){for(let n=0;n<e.length;n+=1){const i=e[n];if(i.nodeType===3)return i.data=\"\"+t,e.splice(n,1)[0]}return R(t)}function ti(e){return Lt(e,\" \")}function ke(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function ni(e,t){e.value=t==null?\"\":t}function ii(e,t){try{e.type=t}catch(n){}}function S(e,t,n,i){e.style.setProperty(t,n,i?\"important\":\"\")}function oi(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t){i.selected=!0;return}}}function li(e,t){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];i.selected=~t.indexOf(i.__value)}}function si(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function ri(e){return[].map.call(e.querySelectorAll(\":checked\"),t=>t.__value)}let be;function Nt(){if(be===void 0){be=!1;try{typeof window!=\"undefined\"&&window.parent&&window.parent.document}catch(e){be=!0}}return be}function ui(e,t){getComputedStyle(e).position===\"static\"&&(e.style.position=\"relative\");const i=F(\"iframe\");i.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),i.setAttribute(\"aria-hidden\",\"true\"),i.tabIndex=-1;const o=Nt();let l;return o?(i.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",l=z(window,\"message\",s=>{s.source===i.contentWindow&&t()})):(i.src=\"about:blank\",i.onload=()=>{l=z(i.contentWindow,\"resize\",t)}),E(e,i),()=>{(o||l&&i.contentWindow)&&l(),j(i)}}function fi(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Ae(e,t){const n=document.createEvent(\"CustomEvent\");return n.initCustomEvent(e,!1,!1,t),n}function ai(e,t=document.body){return Array.from(t.querySelectorAll(e))}class ci{constructor(t=null){this.a=t,this.e=this.n=null}m(t,n,i=null){this.e||(this.e=F(n.nodeName),this.t=n,this.h(t)),this.i(i)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let n=0;n<this.n.length;n+=1)C(this.t,this.n[n],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(j)}}function di(e){const t={};for(const n of e)t[n.name]=n.value;return t}function _i(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||\"default\"]=!0}),t}const Ce=new Set;let ye=0;function Pt(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ce(e,t,n,i,o,l,s,r=0){const f=16.666/i;let a=`{\n",
              "`;for(let u=0;u<=1;u+=f){const _=t+(n-t)*l(u);a+=u*100+`%{${s(_,1-_)}}\n",
              "`}const c=a+`100% {${s(n,1-n)}}\n",
              "}`,d=`__svelte_${Pt(c)}_${r}`,h=e.ownerDocument;Ce.add(h);const p=h.__svelte_stylesheet||(h.__svelte_stylesheet=h.head.appendChild(F(\"style\")).sheet),m=h.__svelte_rules||(h.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${c}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${i}ms linear ${o}ms 1 both`,ye+=1,d}function de(e,t){const n=(e.style.animation||\"\").split(\", \"),i=n.filter(t?l=>l.indexOf(t)<0:l=>l.indexOf(\"__svelte\")===-1),o=n.length-i.length;o&&(e.style.animation=i.join(\", \"),ye-=o,ye||Rt())}function Rt(){ge(()=>{ye||(Ce.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Ce.clear())})}function hi(e,t,n,i){if(!t)return P;const o=e.getBoundingClientRect();if(t.left===o.left&&t.right===o.right&&t.top===o.top&&t.bottom===o.bottom)return P;const{delay:l=0,duration:s=300,easing:r=me,start:f=ae()+l,end:a=f+s,tick:c=P,css:d}=n(e,{from:t,to:o},i);let h=!0,p=!1,m;function g(){d&&(m=ce(e,0,1,s,l,r,d)),l||(p=!0)}function u(){d&&de(e,m),h=!1}return ve(_=>{if(!p&&_>=f&&(p=!0),p&&_>=a&&(c(1,0),u()),!h)return!1;if(p){const k=_-f,w=0+1*r(k/s);c(w,1-w)}return!0}),g(),c(0,1),u}function pi(e){const t=getComputedStyle(e);if(t.position!==\"absolute\"&&t.position!==\"fixed\"){const{width:n,height:i}=t,o=e.getBoundingClientRect();e.style.position=\"absolute\",e.style.width=n,e.style.height=i,Bt(e,o)}}function Bt(e,t){const n=e.getBoundingClientRect();if(t.left!==n.left||t.top!==n.top){const i=getComputedStyle(e),o=i.transform===\"none\"?\"\":i.transform;e.style.transform=`${o} translate(${t.left-n.left}px, ${t.top-n.top}px)`}}let _e;function I(e){_e=e}function U(){if(!_e)throw new Error(\"Function called outside component initialization\");return _e}function mi(e){U().$$.before_update.push(e)}function Ht(e){U().$$.on_mount.push(e)}function gi(e){U().$$.after_update.push(e)}function vi(e){U().$$.on_destroy.push(e)}function ki(){const e=U();return(t,n)=>{const i=e.$$.callbacks[t];if(i){const o=Ae(t,n);i.slice().forEach(l=>{l.call(e,o)})}}}function bi(e,t){U().$$.context.set(e,t)}function yi(e){return U().$$.context.get(e)}function wi(e){return U().$$.context.has(e)}function Fi(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(i=>i(t))}const he=[],qi={enabled:!1},ne=[],we=[],De=[],nt=Promise.resolve();let Oe=!1;function it(){Oe||(Oe=!0,nt.then(Ne))}function Ei(){return it(),nt}function ie(e){we.push(e)}function ot(e){De.push(e)}let Te=!1;const Le=new Set;function Ne(){if(!Te){Te=!0;do{for(let e=0;e<he.length;e+=1){const t=he[e];I(t),xt(t.$$)}for(I(null),he.length=0;ne.length;)ne.pop()();for(let e=0;e<we.length;e+=1){const t=we[e];Le.has(t)||(Le.add(t),t())}we.length=0}while(he.length);for(;De.length;)De.pop()();Oe=!1,Te=!1,Le.clear()}}function xt(e){if(e.fragment!==null){e.update(),H(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(ie)}}let pe;function Pe(){return pe||(pe=Promise.resolve(),pe.then(()=>{pe=null})),pe}function Q(e,t,n){e.dispatchEvent(Ae(`${t?\"intro\":\"outro\"}${n}`))}const Fe=new Set;let V;function oe(){V={r:0,c:[],p:V}}function le(){V.r||H(V.c),V=V.p}function O(e,t){e&&e.i&&(Fe.delete(e),e.i(t))}function L(e,t,n,i){if(e&&e.o){if(Fe.has(e))return;Fe.add(e),V.c.push(()=>{Fe.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}}const Re={duration:0};function Si(e,t,n){let i=t(e,n),o=!1,l,s,r=0;function f(){l&&de(e,l)}function a(){const{delay:d=0,duration:h=300,easing:p=me,tick:m=P,css:g}=i||Re;g&&(l=ce(e,0,1,h,d,p,g,r++)),m(0,1);const u=ae()+d,_=u+h;s&&s.abort(),o=!0,ie(()=>Q(e,!0,\"start\")),s=ve(k=>{if(o){if(k>=_)return m(1,0),Q(e,!0,\"end\"),f(),o=!1;if(k>=u){const w=p((k-u)/h);m(w,1-w)}}return o})}let c=!1;return{start(){c||(de(e),fe(i)?(i=i(),Pe().then(a)):a())},invalidate(){c=!1},end(){o&&(f(),o=!1)}}}function ji(e,t,n){let i=t(e,n),o=!0,l;const s=V;s.r+=1;function r(){const{delay:f=0,duration:a=300,easing:c=me,tick:d=P,css:h}=i||Re;h&&(l=ce(e,1,0,a,f,c,h));const p=ae()+f,m=p+a;ie(()=>Q(e,!1,\"start\")),ve(g=>{if(o){if(g>=m)return d(0,1),Q(e,!1,\"end\"),--s.r||H(s.c),!1;if(g>=p){const u=c((g-p)/a);d(1-u,u)}}return o})}return fe(i)?Pe().then(()=>{i=i(),r()}):r(),{end(f){f&&i.tick&&i.tick(1,0),o&&(l&&de(e,l),o=!1)}}}function Mi(e,t,n,i){let o=t(e,n),l=i?0:1,s=null,r=null,f=null;function a(){f&&de(e,f)}function c(h,p){const m=h.b-l;return p*=Math.abs(m),{a:l,b:h.b,d:m,duration:p,start:h.start,end:h.start+p,group:h.group}}function d(h){const{delay:p=0,duration:m=300,easing:g=me,tick:u=P,css:_}=o||Re,k={start:ae()+p,b:h};h||(k.group=V,V.r+=1),s||r?r=k:(_&&(a(),f=ce(e,l,h,m,p,g,_)),h&&u(0,1),s=c(k,m),ie(()=>Q(e,h,\"start\")),ve(w=>{if(r&&w>r.start&&(s=c(r,m),r=null,Q(e,s.b,\"start\"),_&&(a(),f=ce(e,l,s.b,s.duration,0,g,o.css))),s){if(w>=s.end)u(l=s.b,1-l),Q(e,s.b,\"end\"),r||(s.b?a():--s.group.r||H(s.group.c)),s=null;else if(w>=s.start){const M=w-s.start;l=s.a+s.d*g(M/s.duration),u(l,1-l)}}return!!(s||r)}))}return{run(h){fe(o)?Pe().then(()=>{o=o(),d(h)}):d(h)},end(){a(),s=r=null}}}function Ai(e,t){const n=t.token={};function i(o,l,s,r){if(t.token!==n)return;t.resolved=r;let f=t.ctx;s!==void 0&&(f=f.slice(),f[s]=r);const a=o&&(t.current=o)(f);let c=!1;t.block&&(t.blocks?t.blocks.forEach((d,h)=>{h!==l&&d&&(oe(),L(d,1,1,()=>{t.blocks[h]===d&&(t.blocks[h]=null)}),le())}):t.block.d(1),a.c(),O(a,1),a.m(t.mount(),t.anchor),c=!0),t.block=a,t.blocks&&(t.blocks[l]=a),c&&Ne()}if(Mt(e)){const o=U();if(e.then(l=>{I(o),i(t.then,1,t.value,l),I(null)},l=>{if(I(o),i(t.catch,2,t.error,l),I(null),!t.hasCatch)throw l}),t.current!==t.pending)return i(t.pending,0),!0}else{if(t.current!==t.then)return i(t.then,1,t.value,e),!0;t.resolved=e}}const Ci=typeof window!=\"undefined\"?window:typeof globalThis!=\"undefined\"?globalThis:global;function zt(e,t){e.d(1),t.delete(e.key)}function It(e,t){L(e,1,1,()=>{t.delete(e.key)})}function Di(e,t){e.f(),zt(e,t)}function Oi(e,t){e.f(),It(e,t)}function Ti(e,t,n,i,o,l,s,r,f,a,c,d){let h=e.length,p=l.length,m=h;const g={};for(;m--;)g[e[m].key]=m;const u=[],_=new Map,k=new Map;for(m=p;m--;){const b=d(o,l,m),v=n(b);let q=s.get(v);q?i&&q.p(b,t):(q=a(v,b),q.c()),_.set(v,u[m]=q),v in g&&k.set(v,Math.abs(m-g[v]))}const w=new Set,M=new Set;function N(b){O(b,1),b.m(r,c),s.set(b.key,b),c=b.first,p--}for(;h&&p;){const b=u[p-1],v=e[h-1],q=b.key,D=v.key;b===v?(c=b.first,h--,p--):_.has(D)?!s.has(q)||w.has(q)?N(b):M.has(D)?h--:k.get(q)>k.get(D)?(M.add(q),N(b)):(w.add(D),h--):(f(v,s),h--)}for(;h--;){const b=e[h];_.has(b.key)||f(b,s)}for(;p;)N(u[p-1]);return u}function Li(e,t,n,i){const o=new Set;for(let l=0;l<t.length;l++){const s=i(n(e,t,l));if(o.has(s))throw new Error(\"Cannot have duplicate keys in a keyed each\");o.add(s)}}function Ni(e,t){const n={},i={},o={$$scope:1};let l=e.length;for(;l--;){const s=e[l],r=t[l];if(r){for(const f in s)f in r||(i[f]=1);for(const f in r)o[f]||(n[f]=r[f],o[f]=1);e[l]=r}else for(const f in s)o[f]=1}for(const s in i)s in n||(n[s]=void 0);return n}function Pi(e){return typeof e==\"object\"&&e!==null?e:{}}const Vt=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),Wt=/[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function Ri(e,t){const n=Object.assign({},...e);t&&(n.class==null?n.class=t:n.class+=\" \"+t);let i=\"\";return Object.keys(n).forEach(o=>{if(Wt.test(o))return;const l=n[o];l===!0?i+=\" \"+o:Vt.has(o.toLowerCase())?l&&(i+=\" \"+o):l!=null&&(i+=` ${o}=\"${String(l).replace(/\"/g,\"&#34;\").replace(/'/g,\"&#39;\")}\"`)}),i}const Yt={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function Ut(e){return String(e).replace(/[\"'&<>]/g,t=>Yt[t])}function Bi(e,t){let n=\"\";for(let i=0;i<e.length;i+=1)n+=t(e[i],i);return n}const Hi={$$render:()=>\"\"};function xi(e,t){if(!e||!e.$$render)throw t===\"svelte:component\"&&(t+=\" this={...}\"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return e}function zi(e,t,n,i){return console.log(`{@debug} ${e?e+\" \":\"\"}(${t}:${n})`),console.log(i),\"\"}let Be;function Ii(e){function t(n,i,o,l){const s=_e,r={on_destroy:Be,context:new Map(s?s.$$.context:[]),on_mount:[],before_update:[],after_update:[],callbacks:Se()};I({$$:r});const f=e(n,i,o,l);return I(s),f}return{render:(n={},i={})=>{Be=[];const o={title:\"\",head:\"\",css:new Set},l=t(o,n,{},i);return H(Be),{html:l,css:{code:Array.from(o.css).map(s=>s.code).join(`\n",
              "`),map:null},head:o.title+o.head}},$$render:t}}function Vi(e,t,n){return t==null||n&&!t?\"\":` ${e}${t===!0?\"\":`=${typeof t==\"string\"?JSON.stringify(Ut(t)):`\"${t}\"`}`}`}function Wi(e){return e?` class=\"${e}\"`:\"\"}function lt(e,t,n){const i=e.$$.props[t];i!==void 0&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function se(e){e&&e.c()}function Yi(e,t){e&&e.l(t)}function Z(e,t,n){const{fragment:i,on_mount:o,on_destroy:l,after_update:s}=e.$$;i&&i.m(t,n),ie(()=>{const r=o.map(Ge).filter(fe);l?l.push(...r):H(r),e.$$.on_mount=[]}),s.forEach(ie)}function X(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Jt(e,t){e.$$.dirty[0]===-1&&(he.push(e),it(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function He(e,t,n,i,o,l,s=[-1]){const r=_e;I(e);const f=t.props||{},a=e.$$={fragment:null,ctx:null,props:l,update:P,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(r?r.$$.context:[]),callbacks:Se(),dirty:s,skip_bound:!1};let c=!1;if(a.ctx=n?n(e,f,(d,h,...p)=>{const m=p.length?p[0]:h;return a.ctx&&o(a.ctx[d],a.ctx[d]=m)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](m),c&&Jt(e,d)),h}):[],a.update(),c=!0,H(a.before_update),a.fragment=i?i(a.ctx):!1,t.target){if(t.hydrate){const d=Tt(t.target);a.fragment&&a.fragment.l(d),d.forEach(j)}else a.fragment&&a.fragment.c();t.intro&&O(e.$$.fragment),Z(e,t.target,t.anchor),Ne()}I(r)}let Xt;typeof HTMLElement==\"function\"&&(Xt=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}$destroy(){X(this,1),this.$destroy=P}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Ke(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class xe{$destroy(){X(this,1),this.$destroy=P}$on(t,n){const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(t){this.$$set&&!Ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function W(e,t){document.dispatchEvent(Ae(e,Object.assign({version:\"3.31.2\"},t)))}function Ui(e,t){W(\"SvelteDOMInsert\",{target:e,node:t}),E(e,t)}function Ji(e,t,n){W(\"SvelteDOMInsert\",{target:e,node:t,anchor:n}),C(e,t,n)}function ze(e){W(\"SvelteDOMRemove\",{node:e}),j(e)}function Xi(e,t){for(;e.nextSibling&&e.nextSibling!==t;)ze(e.nextSibling)}function Gi(e){for(;e.previousSibling;)ze(e.previousSibling)}function Ki(e){for(;e.nextSibling;)ze(e.nextSibling)}function Qi(e,t,n,i,o,l){const s=i===!0?[\"capture\"]:i?Array.from(Object.keys(i)):[];o&&s.push(\"preventDefault\"),l&&s.push(\"stopPropagation\"),W(\"SvelteDOMAddEventListener\",{node:e,event:t,handler:n,modifiers:s});const r=z(e,t,n,i);return()=>{W(\"SvelteDOMRemoveEventListener\",{node:e,event:t,handler:n,modifiers:s}),r()}}function Zi(e,t,n){y(e,t,n),n==null?W(\"SvelteDOMRemoveAttribute\",{node:e,attribute:t}):W(\"SvelteDOMSetAttribute\",{node:e,attribute:t,value:n})}function $i(e,t,n){e[t]=n,W(\"SvelteDOMSetProperty\",{node:e,property:t,value:n})}function eo(e,t,n){e.dataset[t]=n,W(\"SvelteDOMSetDataset\",{node:e,property:t,value:n})}function to(e,t){t=\"\"+t,e.wholeText!==t&&(W(\"SvelteDOMSetData\",{node:e,data:t}),e.data=t)}function no(e){if(typeof e!=\"string\"&&!(e&&typeof e==\"object\"&&\"length\"in e)){let t=\"{#each} only iterates over array-like objects.\";throw typeof Symbol==\"function\"&&e&&Symbol.iterator in e&&(t+=\" You can use a spread to convert this iterable into an array.\"),new Error(t)}}function io(e,t,n){for(const i of Object.keys(t))~n.indexOf(i)||console.warn(`<${e}> received an unexpected slot \"${i}\".`)}class oo extends null{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=()=>{console.warn(\"Component was already destroyed\")}}$capture_state(){}$inject_state(){}}class lo extends null{constructor(t){super(t)}}function so(e){const t=Date.now();return()=>{if(Date.now()-t>e)throw new Error(\"Infinite loop detected\")}}function ro(e,t){return e.map((n,i)=>n+t[i])}function uo(e,t){return t.map(n=>e*n)}function Gt(e,t,n){return e.map((i,o)=>(1-n)*i+n*t[o])}function st(e,t=2){if(!(\"length\"in e))return Kt(e,t);for(var n=0,i=0;i<e.length;i++)n+=Math.pow(Math.abs(e[i]),t);return Math.pow(n,1/t)}function Kt(e,t=2){for(var n=0,i=0;i<e.shape[0];i++)n+=Math.pow(Math.abs(e.get(i)),t);return Math.pow(n,1/t)}function Ie(e,t=2){var n=st(e,t);return e.map(i=>i/(1e-4+n))}function Qt(e){for(var t=[[1,0,0],[1,1,0],[0,1,0],[0,1,1],[0,0,1],[1,0,1]].map(s=>Ie(s,1));e<0;)e+=360;e=e%360;var n=360/t.length,i=Math.floor(e/n),o=(e-i*n)/n,l=Gt(t[i],t[(i+1)%t.length],o);return l=Ie(l,1),l}const Ve=[];function Zt(e){if(e in Ve)return Ve[e];let t=[];for(let n=0;n<e;n++){const i=360*n/e;t.push(Qt(i))}return Ve[e]=t,t}function rt(e){return`rgb(${255*e[0]}, ${255*e[1]}, ${255*e[2]})`}function ut(e,t=[.98,.98,.98],n=void 0,i=void 0){const o=\"length\"in e?e.length:e.shape[0],l=\"length\"in e?h=>e[h]:h=>e.get(h);if(i==null&&(i=Zt(o)),console.log(\"Hues\",i),n==null){for(var s=[0,0,0],r=0;r<o;r++){const h=l(r);if(h!=0)for(var f=i[r],a=0;a<3;a++)s[a]+=h*f[a]}s=Ie(s,1);for(var c=st(e,2),c=Math.max(0,Math.min(1,c)),a=0;a<3;a++)s[a]=c*s[a]+(1-c)*t[a];return s}else{for(var r=n,d=i[r],s=[0,0,0],a=0;a<3;a++)s[a]=l(r)*d[a]+(1-l(r))*t[a];return s}}function We(e,t=[.98,.98,.98],n=void 0,i=void 0){var o=ut(e,t,n,i);return rt(o)}function $t(e,t=[.98,.98,.98]){if(e>=0)for(var n=[0,.7,0],i=[0,0,0],o=0;o<3;o++)i[o]=e*n[o]+(1-e)*t[o];else for(var n=[1,0,0],i=[0,0,0],o=0;o<3;o++)i[o]=-e*n[o]+(1+e)*t[o];return console.log(\"Neuron color\",e,i),i}function fo(e,t=[.98,.98,.98]){var n=$t(e,t);return rt(n)}function en(){var e=F(\"style\");e.id=\"svelte-1fjpmsy-style\",e.textContent=\".container.svelte-1fjpmsy.svelte-1fjpmsy{position:relative;border:1px solid #aaa}.container.svelte-1fjpmsy>.svelte-1fjpmsy{position:absolute}.container.svelte-1fjpmsy canvas.svelte-1fjpmsy{left:0px;top:0px;width:100%;height:100%;image-rendering:pixelated}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{left:0px;width:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-top.svelte-1fjpmsy{top:0px}.container.svelte-1fjpmsy .focus-bottom.svelte-1fjpmsy{bottom:0px}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy,.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{top:0px;height:100%;background:#aaa;opacity:0.3}.container.svelte-1fjpmsy .focus-left.svelte-1fjpmsy{left:0px}.container.svelte-1fjpmsy .focus-right.svelte-1fjpmsy{right:0px}\",E(document.head,e)}function ft(e){let t,n,i,o=e[3]!=null&&at(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[9](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=at(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[9](null),o&&o.d()}}}function at(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-top svelte-1fjpmsy\"),S(t,\"height\",e[2]*e[3]/e[0].shape[0]+\"px\"),y(i,\"class\",\"focus-bottom svelte-1fjpmsy\"),S(i,\"height\",e[2]*(1-(e[3]+1)/e[0].shape[0])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&13&&S(t,\"height\",o[2]*o[3]/o[0].shape[0]+\"px\"),l&13&&S(i,\"height\",o[2]*(1-(o[3]+1)/o[0].shape[0])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function ct(e){let t,n,i,o=e[3]!=null&&dt(e);return{c(){t=F(\"div\"),n=F(\"canvas\"),i=T(),o&&o.c(),S(n,\"width\",e[1]+\"px\"),S(n,\"height\",e[2]+\"px\"),y(n,\"class\",\"svelte-1fjpmsy\"),y(t,\"class\",\"container svelte-1fjpmsy\"),S(t,\"width\",e[1]+\"px\"),S(t,\"height\",e[2]+\"px\")},m(l,s){C(l,t,s),E(t,n),e[10](n),E(t,i),o&&o.m(t,null)},p(l,s){s&2&&S(n,\"width\",l[1]+\"px\"),s&4&&S(n,\"height\",l[2]+\"px\"),l[3]!=null?o?o.p(l,s):(o=dt(l),o.c(),o.m(t,null)):o&&(o.d(1),o=null),s&2&&S(t,\"width\",l[1]+\"px\"),s&4&&S(t,\"height\",l[2]+\"px\")},d(l){l&&j(t),e[10](null),o&&o.d()}}}function dt(e){let t,n,i;return{c(){t=F(\"div\"),n=T(),i=F(\"div\"),y(t,\"class\",\"focus-left svelte-1fjpmsy\"),S(t,\"width\",e[1]*e[3]/e[0].shape[1]+\"px\"),y(i,\"class\",\"focus-right svelte-1fjpmsy\"),S(i,\"width\",e[1]*(1-(e[3]+1)/e[0].shape[1])+\"px\")},m(o,l){C(o,t,l),C(o,n,l),C(o,i,l)},p(o,l){l&11&&S(t,\"width\",o[1]*o[3]/o[0].shape[1]+\"px\"),l&11&&S(i,\"width\",o[1]*(1-(o[3]+1)/o[0].shape[1])+\"px\")},d(o){o&&j(t),o&&j(n),o&&j(i)}}}function tn(e){let t,n,i=!e[4]&&ft(e),o=e[4]&&ct(e);return{c(){i&&i.c(),t=T(),o&&o.c(),n=tt()},m(l,s){i&&i.m(l,s),C(l,t,s),o&&o.m(l,s),C(l,n,s)},p(l,[s]){l[4]?i&&(i.d(1),i=null):i?i.p(l,s):(i=ft(l),i.c(),i.m(t.parentNode,t)),l[4]?o?o.p(l,s):(o=ct(l),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:P,o:P,d(l){i&&i.d(l),l&&j(t),o&&o.d(l),l&&j(n)}}}function nn(e,t,n){let{array:i}=t,{width:o}=t,{height:l}=t,{hues:s}=t,{focus_token:r}=t,{isolate_channel:f=void 0}=t,{hover_token_is_target:a=!1}=t,{color_map:c=ut}=t,d;function h(u,_,k,w=void 0,M=void 0){if(_<k)return[255,255,255];var N=u.pick(_,k,null),b=c(N,void 0,w,M);return b.map(v=>255*v)}function p(u,_,k=void 0,w=void 0){if(!(u==null||_==null)){u.width=_.shape[0],u.height=_.shape[1];for(var M=u.getContext(\"2d\"),N=M.getImageData(0,0,u.width,u.height),b=0;b<u.width;b++)for(var v=0;v<u.height;v++){for(var q=b*u.width+v,D=h(_,b,v,k,w=w),J=0;J<3;J++)N.data[4*q+J]=D[J];N.data[4*q+3]=255}M.putImageData(N,0,0)}}Ht(()=>p(d,i,f));function m(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}function g(u){ne[u?\"unshift\":\"push\"](()=>{d=u,n(5,d)})}return e.$$set=u=>{\"array\"in u&&n(0,i=u.array),\"width\"in u&&n(1,o=u.width),\"height\"in u&&n(2,l=u.height),\"hues\"in u&&n(6,s=u.hues),\"focus_token\"in u&&n(3,r=u.focus_token),\"isolate_channel\"in u&&n(7,f=u.isolate_channel),\"hover_token_is_target\"in u&&n(4,a=u.hover_token_is_target),\"color_map\"in u&&n(8,c=u.color_map)},e.$$.update=()=>{if(e.$$.dirty&225){e:p(d,i,f,s)}},[i,o,l,r,a,d,s,f,c,m,g]}class on extends xe{constructor(t){super(),document.getElementById(\"svelte-1fjpmsy-style\")||en(),He(this,t,nn,tn,je,{array:0,width:1,height:2,hues:6,focus_token:3,isolate_channel:7,hover_token_is_target:4,color_map:8})}}const qe=on;function _t(e,t){return e.mode==\"soft\"&&(e.value=t),e}function ln(e,t){if(e.mode==\"soft\")e.value=t,e.mode=\"hard\";else if(e.mode==\"hard\"&&e.value!=t)e.value=t;else return sn(e);return e}function sn(e){return e.value=void 0,e.mode=\"soft\",e}function rn(e){let t,n,i,o;const l=e[4].default,s=At(l,e,e[3],null);return{c(){t=F(\"div\"),s&&s.c(),y(t,\"style\",e[2])},m(r,f){C(r,t,f),s&&s.m(t,null),n=!0,i||(o=[z(t,\"mouseover\",e[5]),z(t,\"click\",e[6]),z(t,\"mouseout\",e[7])],i=!0)},p(r,[f]){s&&s.p&&f&8&&Ct(s,l,r,r[3],f,null,null),(!n||f&4)&&y(t,\"style\",r[2])},i(r){n||(O(s,r),n=!0)},o(r){L(s,r),n=!1},d(r){r&&j(t),s&&s.d(r),i=!1,H(o)}}}function un(e,t,n){let{$$slots:i={},$$scope:o}=t,{lock:l}=t,{set_value:s}=t,{style:r=\"\"}=t;const f=()=>{n(0,l=_t(l,s))},a=()=>{n(0,l=ln(l,s))},c=()=>{n(0,l=_t(l,void 0))};return e.$$set=d=>{\"lock\"in d&&n(0,l=d.lock),\"set_value\"in d&&n(1,s=d.set_value),\"style\"in d&&n(2,r=d.style),\"$$scope\"in d&&n(3,o=d.$$scope)},[l,s,r,o,i,f,a,c]}class fn extends xe{constructor(t){super(),He(this,t,un,rn,je,{lock:0,set_value:1,style:2})}}const ht=fn;function an(){var e=F(\"style\");e.id=\"svelte-xqk9oe-style\",e.textContent=\".attn-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[big-attn] min-content [heads] minmax(min-content, 624px);gap:12px}.figcaption.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;white-space:nowrap}.tokens-container.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{display:grid;grid-template-rows:[title] min-content [main] min-content;grid-template-columns:[left] min-content [right] minmax(min-content, 800px) [end];gap:12px;margin-top:24px;color:white}.tokens.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-row:main;grid-column-start:left;grid-column-end:end;cursor:pointer;height:min-content;line-height:110%}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe{white-space:pre-wrap}.tokens.svelte-xqk9oe .selected.svelte-xqk9oe.svelte-xqk9oe{border:1px solid #999;z-index:10}.tokens.svelte-xqk9oe .token.svelte-xqk9oe.svelte-xqk9oe:not(.selected){z-index:0;padding:1px}.hover-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{color:#888;grid-row:title;grid-column:settings;cursor:pointer}.hover-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe,.info-mode-text.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{margin-right:8px}.heads.svelte-xqk9oe.svelte-xqk9oe.svelte-xqk9oe{grid-column:heads;grid-row:main;display:flex;flex-direction:row;flex-wrap:wrap;gap:6px;height:min-content}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe.svelte-xqk9oe{position:relative;width:62px;height:62px}.heads.svelte-xqk9oe .head-icon.svelte-xqk9oe>.svelte-xqk9oe{position:absolute;right:0px;top:0px}.heads.svelte-xqk9oe .head-icon .head-label.svelte-xqk9oe.svelte-xqk9oe{background:#333;color:#eee;font-size:65%;padding:1px;border-bottom-left-radius:2px;padding-left:4px;padding-right:2px;min-width:14px;opacity:0.75}\",E(document.head,e)}function pt(e,t,n){const i=e.slice();return i[32]=t[n],i[34]=n,i}function mt(e,t,n){const i=e.slice();return i[35]=t[n],i}function gt(e){let t,n=e[15][e[10]]+\"\",i,o;return{c(){t=R(\"(\"),i=R(n),o=R(\")\")},m(l,s){C(l,t,s),C(l,i,s),C(l,o,s)},p(l,s){s[0]&33792&&n!==(n=l[15][l[10]]+\"\")&&ke(i,n)},d(l){l&&j(t),l&&j(i),l&&j(o)}}}function vt(e){let t,n,i,o;return n=new qe({props:{array:e[7],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}}),{c(){t=F(\"div\"),se(n.$$.fragment),y(t,\"style\",i=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"\":\"display:none;\"))},m(l,s){C(l,t,s),Z(n,t,null),o=!0},p(l,s){const r={};s[0]&128&&(r.array=l[7]),s[0]&512&&(r.focus_token=l[9]),s[0]&4&&(r.hover_token_is_target=l[2]),s[0]&1024&&(r.isolate_channel=l[10]),n.$set(r),(!o||s[0]&2048&&i!==(i=\"grid-column: big-attn; grid-row: main; \"+(l[11]?\"\":\"display:none;\")))&&y(t,\"style\",i)},i(l){o||(O(n.$$.fragment,l),o=!0)},o(l){L(n.$$.fragment,l),o=!1},d(l){l&&j(t),X(n)}}}function kt(e){let t,n,i,o,l=re(e[12].shape[2]),s=[];for(let f=0;f<l.length;f+=1)s[f]=bt(mt(e,l,f));const r=f=>L(s[f],1,1,()=>{s[f]=null});return{c(){t=F(\"div\"),t.textContent=\"Attention Heads (hover to focus, click to lock)\",n=T(),i=F(\"div\");for(let f=0;f<s.length;f+=1)s[f].c();y(t,\"class\",\"figcaption svelte-xqk9oe\"),S(t,\"grid-column\",\"heads\"),y(i,\"class\",\"heads svelte-xqk9oe\")},m(f,a){C(f,t,a),C(f,n,a),C(f,i,a);for(let c=0;c<s.length;c+=1)s[c].m(i,null);o=!0},p(f,a){if(a[0]&122566){l=re(f[12].shape[2]);let c;for(c=0;c<l.length;c+=1){const d=mt(f,l,c);s[c]?(s[c].p(d,a),O(s[c],1)):(s[c]=bt(d),s[c].c(),O(s[c],1),s[c].m(i,null))}for(oe(),c=l.length;c<s.length;c+=1)r(c);le()}},i(f){if(!o){for(let a=0;a<l.length;a+=1)O(s[a]);o=!0}},o(f){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)L(s[a]);o=!1},d(f){f&&j(t),f&&j(n),f&&j(i),et(s,f)}}}function cn(e){let t,n,i,o,l=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",s,r,f,a,c,d,h=(e[15][e[35]]!=null?e[15][e[35]]:\"&nbsp\")+\"\",p,m,g;return n=new qe({props:{array:e[7],width:\"60\",height:\"60\",isolate_channel:e[35]}}),a=new qe({props:{array:e[6],width:\"60\",height:\"60\",isolate_channel:e[35]}}),{c(){t=F(\"div\"),se(n.$$.fragment),i=T(),o=F(\"div\"),r=T(),f=F(\"div\"),se(a.$$.fragment),c=T(),d=F(\"div\"),m=T(),y(o,\"class\",\"head-label svelte-xqk9oe\"),S(o,\"background\",e[14][e[35]]),y(t,\"class\",\"head-icon svelte-xqk9oe\"),y(t,\"style\",s=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"\":\"display:none;\")),y(d,\"class\",\"head-label svelte-xqk9oe\"),S(d,\"background\",e[14][e[35]]),y(f,\"class\",\"head-icon svelte-xqk9oe\"),y(f,\"style\",p=\"opacity: \"+(e[10]!=null&&e[10]!=e[35]?\"0.2\":e[16](e[35],e[9],e[2]))+`;\n",
              "                        `+(e[11]?\"display:none;\":\"\"))},m(u,_){C(u,t,_),Z(n,t,null),E(t,i),E(t,o),o.innerHTML=l,C(u,r,_),C(u,f,_),Z(a,f,null),E(f,c),E(f,d),d.innerHTML=h,C(u,m,_),g=!0},p(u,_){const k={};_[0]&128&&(k.array=u[7]),_[0]&4096&&(k.isolate_channel=u[35]),n.$set(k),(!g||_[0]&36864)&&l!==(l=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(o.innerHTML=l),(!g||_[0]&20480)&&S(o,\"background\",u[14][u[35]]),(!g||_[0]&7684&&s!==(s=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"\":\"display:none;\")))&&y(t,\"style\",s);const w={};_[0]&64&&(w.array=u[6]),_[0]&4096&&(w.isolate_channel=u[35]),a.$set(w),(!g||_[0]&36864)&&h!==(h=(u[15][u[35]]!=null?u[15][u[35]]:\"&nbsp\")+\"\")&&(d.innerHTML=h),(!g||_[0]&20480)&&S(d,\"background\",u[14][u[35]]),(!g||_[0]&7684&&p!==(p=\"opacity: \"+(u[10]!=null&&u[10]!=u[35]?\"0.2\":u[16](u[35],u[9],u[2]))+`;\n",
              "                        `+(u[11]?\"display:none;\":\"\")))&&y(f,\"style\",p)},i(u){g||(O(n.$$.fragment,u),O(a.$$.fragment,u),g=!0)},o(u){L(n.$$.fragment,u),L(a.$$.fragment,u),g=!1},d(u){u&&j(t),X(n),u&&j(r),u&&j(f),X(a),u&&j(m)}}}function bt(e){let t,n,i;function o(s){e[22].call(null,s)}let l={set_value:e[35],$$slots:{default:[cn]},$$scope:{ctx:e}};return e[1]!==void 0&&(l.lock=e[1]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&4096&&(f.set_value=s[35]),r[0]&57028|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&2&&(n=!0,f.lock=s[1],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function yt(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[2]?\"target\":\"source\",m,g,u,_,k,w=e[5],M=[];for(let v=0;v<w.length;v+=1)M[v]=wt(pt(e,w,v));const N=v=>L(M[v],1,1,()=>{M[v]=null});let b=e[7]!==void 0&&Ft(e);return{c(){t=F(\"div\"),n=F(\"div\"),n.textContent=\"Tokens (hover to focus, click to lock)\",i=T(),o=F(\"div\");for(let v=0;v<M.length;v+=1)M[v].c();l=T(),s=F(\"div\"),r=F(\"nobr\"),f=F(\"input\"),a=T(),c=F(\"span\"),d=R(`Selected is\n",
              "            `),h=F(\"b\"),m=R(p),g=T(),b&&b.c(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"left\"),y(o,\"class\",\"tokens svelte-xqk9oe\"),y(f,\"class\",\"hover-mode svelte-xqk9oe\"),y(f,\"type\",\"checkbox\"),y(c,\"class\",\"hover-mode-text svelte-xqk9oe\"),S(c,\"white-space\",\"nowrap\"),y(s,\"class\",\"toggle\"),y(t,\"class\",\"tokens-container svelte-xqk9oe\")},m(v,q){C(v,t,q),E(t,n),E(t,i),E(t,o);for(let D=0;D<M.length;D+=1)M[D].m(o,null);E(t,l),E(t,s),E(s,r),E(r,f),f.checked=e[2],E(r,a),E(r,c),E(c,d),E(c,h),E(h,m),E(r,g),b&&b.m(r,null),u=!0,_||(k=[z(f,\"change\",e[24]),z(c,\"click\",e[25])],_=!0)},p(v,q){if(q[0]&561){w=v[5];let D;for(D=0;D<w.length;D+=1){const J=pt(v,w,D);M[D]?(M[D].p(J,q),O(M[D],1)):(M[D]=wt(J),M[D].c(),O(M[D],1),M[D].m(o,null))}for(oe(),D=w.length;D<M.length;D+=1)N(D);le()}q[0]&4&&(f.checked=v[2]),(!u||q[0]&4)&&p!==(p=v[2]?\"target\":\"source\")&&ke(m,p),v[7]!==void 0?b?b.p(v,q):(b=Ft(v),b.c(),b.m(r,null)):b&&(b.d(1),b=null)},i(v){if(!u){for(let q=0;q<w.length;q+=1)O(M[q]);u=!0}},o(v){M=M.filter(Boolean);for(let q=0;q<M.length;q+=1)L(M[q]);u=!1},d(v){v&&j(t),et(M,v),b&&b.d(),_=!1,H(k)}}}function dn(e){let t,n=e[32]+\"\",i,o;return{c(){t=F(\"span\"),i=R(n),y(t,\"class\",o=\"token \"+(e[34]==e[9]?\"selected\":\"\")+\" svelte-xqk9oe\"),S(t,\"background\",e[4][e[34]])},m(l,s){C(l,t,s),E(t,i)},p(l,s){s[0]&32&&n!==(n=l[32]+\"\")&&ke(i,n),s[0]&512&&o!==(o=\"token \"+(l[34]==l[9]?\"selected\":\"\")+\" svelte-xqk9oe\")&&y(t,\"class\",o),s[0]&16&&S(t,\"background\",l[4][l[34]])},d(l){l&&j(t)}}}function wt(e){let t,n,i;function o(s){e[23].call(null,s)}let l={set_value:e[34],style:\"display: inline\",$$slots:{default:[dn]},$$scope:{ctx:e}};return e[0]!==void 0&&(l.lock=e[0]),t=new ht({props:l}),ne.push(()=>lt(t,\"lock\",o)),{c(){se(t.$$.fragment)},m(s,r){Z(t,s,r),i=!0},p(s,r){const f={};r[0]&560|r[1]&128&&(f.$$scope={dirty:r,ctx:s}),!n&&r[0]&1&&(n=!0,f.lock=s[0],ot(()=>n=!1)),t.$set(f)},i(s){i||(O(t.$$.fragment,s),i=!0)},o(s){L(t.$$.fragment,s),i=!1},d(s){X(t,s)}}}function Ft(e){let t,n,i,o,l,s=e[3]?\"info-weighted\":\"unmodified\",r,f,a;return{c(){t=F(\"input\"),n=T(),i=F(\"span\"),o=R(`Attention is\n",
              "            `),l=F(\"b\"),r=R(s),y(t,\"class\",\"info-mode svelte-xqk9oe\"),y(t,\"type\",\"checkbox\"),y(i,\"class\",\"info-mode-text svelte-xqk9oe\"),S(i,\"white-space\",\"nowrap\")},m(c,d){C(c,t,d),t.checked=e[3],C(c,n,d),C(c,i,d),E(i,o),E(i,l),E(l,r),f||(a=[z(t,\"change\",e[26]),z(i,\"click\",e[27])],f=!0)},p(c,d){d[0]&8&&(t.checked=c[3]),d[0]&8&&s!==(s=c[3]?\"info-weighted\":\"unmodified\")&&ke(r,s)},d(c){c&&j(t),c&&j(n),c&&j(i),f=!1,H(a)}}}function _n(e){let t,n,i,o,l,s,r,f,a,c,d,h,p=e[10]!=null&&gt(e),m=e[7]!==void 0&&vt(e);r=new qe({props:{array:e[6],width:\"200\",height:\"200\",focus_token:e[9],hover_token_is_target:e[2],isolate_channel:e[10]}});let g=e[13]>1&&kt(e),u=e[8]&&yt(e);return{c(){t=F(\"div\"),n=F(\"div\"),i=R(`Attention Pattern\n",
              "        `),p&&p.c(),o=T(),m&&m.c(),l=T(),s=F(\"div\"),se(r.$$.fragment),a=T(),g&&g.c(),c=T(),u&&u.c(),d=tt(),y(n,\"class\",\"figcaption svelte-xqk9oe\"),S(n,\"grid-column\",\"big-attn\"),y(s,\"style\",f=\"grid-column: big-attn; grid-row: main; \"+(e[11]?\"display:none\":\"\")),y(t,\"class\",\"attn-container svelte-xqk9oe\")},m(_,k){C(_,t,k),E(t,n),E(n,i),p&&p.m(n,null),E(t,o),m&&m.m(t,null),E(t,l),E(t,s),Z(r,s,null),E(t,a),g&&g.m(t,null),C(_,c,k),u&&u.m(_,k),C(_,d,k),h=!0},p(_,k){_[10]!=null?p?p.p(_,k):(p=gt(_),p.c(),p.m(n,null)):p&&(p.d(1),p=null),_[7]!==void 0?m?(m.p(_,k),k[0]&128&&O(m,1)):(m=vt(_),m.c(),O(m,1),m.m(t,l)):m&&(oe(),L(m,1,1,()=>{m=null}),le());const w={};k[0]&64&&(w.array=_[6]),k[0]&512&&(w.focus_token=_[9]),k[0]&4&&(w.hover_token_is_target=_[2]),k[0]&1024&&(w.isolate_channel=_[10]),r.$set(w),(!h||k[0]&2048&&f!==(f=\"grid-column: big-attn; grid-row: main; \"+(_[11]?\"display:none\":\"\")))&&y(s,\"style\",f),_[13]>1?g?(g.p(_,k),k[0]&8192&&O(g,1)):(g=kt(_),g.c(),O(g,1),g.m(t,null)):g&&(oe(),L(g,1,1,()=>{g=null}),le()),_[8]?u?(u.p(_,k),k[0]&256&&O(u,1)):(u=yt(_),u.c(),O(u,1),u.m(d.parentNode,d)):u&&(oe(),L(u,1,1,()=>{u=null}),le())},i(_){h||(O(m),O(r.$$.fragment,_),O(g),O(u),h=!0)},o(_){L(m),L(r.$$.fragment,_),L(g),L(u),h=!1},d(_){_&&j(t),p&&p.d(),m&&m.d(),X(r),g&&g.d(),_&&j(c),u&&u.d(_),_&&j(d)}}}function re(e){return[...Array(e).keys()]}function qt(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(n,l,i));t[n].push(o)}}return t}}function Et(e){if(e!==void 0){for(var t=[],n=0;n<e.shape[0];n++){t.push([]);for(var i=0;i<e.shape[2];i++){for(var o=0,l=0;l<e.shape[1];l++)o=Math.max(o,e.pick(l,n,i));t[n].push(o)}}return t}}function hn(e,t,n){let i,o,l,s,r,f,a,c,d,h,p,m,g,{tokens:u}=t,{attention:_}=t,{info_weighted:k}=t,{head_labels:w}=t,{show_tokens:M=!0}=t,{focus_token_lock:N={value:void 0,mode:\"soft\"}}=t,{focus_head_lock:b={value:void 0,mode:\"soft\"}}=t,{hover_token_is_target:v=!1}=t,{_show_info_weighted:q=!1}=t;function D(A,Y,G,$=void 0){if(Y<G)return\"#FFF\";var ue=A.pick(Y,G,null);return We(ue,void 0,$)}function J(A,Y,G){if(Y==null)var $=1;else var ue=G?h:d,$=Math.max(0,Math.min(1,ue[Y][A]));return\"\"+$}function gn(A,Y,G,$=void 0,ue){if(Y==null){var qn=ue?h:d;return We(qn[G],void 0,$)}let Ue,Je;ue?(Ue=G,Je=Y):(Ue=Y,Je=G);let Xe=D(A,Ue,Je,$);return Xe===\"#FFF\"&&(Xe=\"#DDD\"),Xe}let{all_token_colors:Ye}=t;function vn(A){b=A,n(1,b)}function kn(A){N=A,n(0,N)}function bn(){v=this.checked,n(2,v)}const yn=()=>n(2,v=v^!0);function wn(){q=this.checked,n(3,q)}const Fn=()=>n(3,q=q^!0);return e.$$set=A=>{\"tokens\"in A&&n(5,u=A.tokens),\"attention\"in A&&n(6,_=A.attention),\"info_weighted\"in A&&n(7,k=A.info_weighted),\"head_labels\"in A&&n(17,w=A.head_labels),\"show_tokens\"in A&&n(8,M=A.show_tokens),\"focus_token_lock\"in A&&n(0,N=A.focus_token_lock),\"focus_head_lock\"in A&&n(1,b=A.focus_head_lock),\"hover_token_is_target\"in A&&n(2,v=A.hover_token_is_target),\"_show_info_weighted\"in A&&n(3,q=A._show_info_weighted),\"all_token_colors\"in A&&n(4,Ye=A.all_token_colors)},e.$$.update=()=>{if(e.$$.dirty[0]&1){e:n(9,i=N.value)}if(e.$$.dirty[0]&2){e:n(10,o=b.value)}if(e.$$.dirty[0]&136){e:n(11,l=q&&k!==void 0)}if(e.$$.dirty[0]&2240){e:n(12,s=l?k:_)}if(e.$$.dirty[0]&4096){e:window.attention_show=s}if(e.$$.dirty[0]&64){e:n(18,r=qt(_))}if(e.$$.dirty[0]&64){e:n(19,f=Et(_))}if(e.$$.dirty[0]&128){e:n(20,a=qt(k))}if(e.$$.dirty[0]&128){e:n(21,c=Et(k))}if(e.$$.dirty[0]&1312768){e:d=l?a:r}if(e.$$.dirty[0]&2623488){e:h=l?c:f}if(e.$$.dirty[0]&64){e:n(13,p=_.shape[2])}if(e.$$.dirty[0]&8192){e:n(14,m=re(p).map(A=>We(re(p).map(Y=>1),void 0,A)))}if(e.$$.dirty[0]&139264){e:n(15,g=w!=null?w:re(p))}if(e.$$.dirty[0]&5668){e:n(4,Ye=re(u.length).map(A=>gn(s,i,A,o,v)))}},[N,b,v,q,Ye,u,_,k,M,i,o,l,s,p,m,g,J,w,r,f,a,c,vn,kn,bn,yn,wn,Fn]}class pn extends xe{constructor(t){super(),document.getElementById(\"svelte-xqk9oe-style\")||an(),He(this,t,hn,_n,je,{tokens:5,attention:6,info_weighted:7,head_labels:17,show_tokens:8,focus_token_lock:0,focus_head_lock:1,hover_token_is_target:2,_show_info_weighted:3,all_token_colors:4},[-1,-1])}}const mn=pn}},Ee={};function ee(x){if(Ee[x])return Ee[x].exports;var B=Ee[x]={exports:{}};return St[x](B,B.exports,ee),B.exports}return ee.d=(x,B)=>{for(var te in B)ee.o(B,te)&&!ee.o(x,te)&&Object.defineProperty(x,te,{enumerable:!0,get:B[te]})},ee.o=(x,B)=>Object.prototype.hasOwnProperty.call(x,B),ee(143)})().default;\n",
              "</script>\n",
              "<script>var loader;loader=(()=>{var Ze={907:k=>{\"use strict\";function I(E){for(var T=new Array(E),n=0;n<E;++n)T[n]=n;return T}k.exports=I},738:k=>{/*!\n",
              " * Determine if an object is a Buffer\n",
              " *\n",
              " * @author   Feross Aboukhadijeh <https://feross.org>\n",
              " * @license  MIT\n",
              " */k.exports=function(T){return T!=null&&(I(T)||E(T)||!!T._isBuffer)};function I(T){return!!T.constructor&&typeof T.constructor.isBuffer==\"function\"&&T.constructor.isBuffer(T)}function E(T){return typeof T.readFloatLE==\"function\"&&typeof T.slice==\"function\"&&I(T.slice(0,0))}},861:(k,I,E)=>{var T=E(907),n=E(738),g=typeof Float64Array!=\"undefined\";function s(l,h){return l[0]-h[0]}function m(){var l=this.stride,h=new Array(l.length),c;for(c=0;c<h.length;++c)h[c]=[Math.abs(l[c]),c];h.sort(s);var N=new Array(h.length);for(c=0;c<N.length;++c)N[c]=h[c][1];return N}function _(l,h){var c=[\"View\",h,\"d\",l].join(\"\");h<0&&(c=\"View_Nil\"+l);var N=l===\"generic\";if(h===-1){var f=\"function \"+c+\"(a){this.data=a;};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new \"+c+\"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_\"+c+\"(a){return new \"+c+\"(a);}\",O=new Function(f);return O()}else if(h===0){var f=\"function \"+c+\"(a,d) {this.data = a;this.offset = d};var proto=\"+c+\".prototype;proto.dtype='\"+l+\"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function \"+c+\"_copy() {return new \"+c+\"(this.data,this.offset)};proto.pick=function \"+c+\"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function \"+c+\"_get(){return \"+(N?\"this.data.get(this.offset)\":\"this.data[this.offset]\")+\"};proto.set=function \"+c+\"_set(v){return \"+(N?\"this.data.set(this.offset,v)\":\"this.data[this.offset]=v\")+\"};return function construct_\"+c+\"(a,b,c,d){return new \"+c+\"(a,d)}\",O=new Function(\"TrivialArray\",f);return O(u[l][0])}var f=[\"'use strict'\"],d=T(h),M=d.map(function(p){return\"i\"+p}),L=\"this.offset+\"+d.map(function(p){return\"this.stride[\"+p+\"]*i\"+p}).join(\"+\"),j=d.map(function(p){return\"b\"+p}).join(\",\"),D=d.map(function(p){return\"c\"+p}).join(\",\");f.push(\"function \"+c+\"(a,\"+j+\",\"+D+\",d){this.data=a\",\"this.shape=[\"+j+\"]\",\"this.stride=[\"+D+\"]\",\"this.offset=d|0}\",\"var proto=\"+c+\".prototype\",\"proto.dtype='\"+l+\"'\",\"proto.dimension=\"+h),f.push(\"Object.defineProperty(proto,'size',{get:function \"+c+\"_size(){return \"+d.map(function(p){return\"this.shape[\"+p+\"]\"}).join(\"*\"),\"}})\"),h===1?f.push(\"proto.order=[0]\"):(f.push(\"Object.defineProperty(proto,'order',{get:\"),h<4?(f.push(\"function \"+c+\"_order(){\"),h===2?f.push(\"return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})\"):h===3&&f.push(\"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})\")):f.push(\"ORDER})\")),f.push(\"proto.set=function \"+c+\"_set(\"+M.join(\",\")+\",v){\"),N?f.push(\"return this.data.set(\"+L+\",v)}\"):f.push(\"return this.data[\"+L+\"]=v}\"),f.push(\"proto.get=function \"+c+\"_get(\"+M.join(\",\")+\"){\"),N?f.push(\"return this.data.get(\"+L+\")}\"):f.push(\"return this.data[\"+L+\"]}\"),f.push(\"proto.index=function \"+c+\"_index(\",M.join(),\"){return \"+L+\"}\"),f.push(\"proto.hi=function \"+c+\"_hi(\"+M.join(\",\")+\"){return new \"+c+\"(this.data,\"+d.map(function(p){return[\"(typeof i\",p,\"!=='number'||i\",p,\"<0)?this.shape[\",p,\"]:i\",p,\"|0\"].join(\"\")}).join(\",\")+\",\"+d.map(function(p){return\"this.stride[\"+p+\"]\"}).join(\",\")+\",this.offset)}\");var A=d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}),o=d.map(function(p){return\"c\"+p+\"=this.stride[\"+p+\"]\"});f.push(\"proto.lo=function \"+c+\"_lo(\"+M.join(\",\")+\"){var b=this.offset,d=0,\"+A.join(\",\")+\",\"+o.join(\",\"));for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){d=i\"+i+\"|0;b+=c\"+i+\"*d;a\"+i+\"-=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"c\"+p}).join(\",\")+\",b)}\"),f.push(\"proto.step=function \"+c+\"_step(\"+M.join(\",\")+\"){var \"+d.map(function(p){return\"a\"+p+\"=this.shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p+\"=this.stride[\"+p+\"]\"}).join(\",\")+\",c=this.offset,d=0,ceil=Math.ceil\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'){d=i\"+i+\"|0;if(d<0){c+=b\"+i+\"*(a\"+i+\"-1);a\"+i+\"=ceil(-a\"+i+\"/d)}else{a\"+i+\"=ceil(a\"+i+\"/d)}b\"+i+\"*=d}\");f.push(\"return new \"+c+\"(this.data,\"+d.map(function(p){return\"a\"+p}).join(\",\")+\",\"+d.map(function(p){return\"b\"+p}).join(\",\")+\",c)}\");for(var Z=new Array(h),R=new Array(h),i=0;i<h;++i)Z[i]=\"a[i\"+i+\"]\",R[i]=\"b[i\"+i+\"]\";f.push(\"proto.transpose=function \"+c+\"_transpose(\"+M+\"){\"+M.map(function(p,U){return p+\"=(\"+p+\"===undefined?\"+U+\":\"+p+\"|0)\"}).join(\";\"),\"var a=this.shape,b=this.stride;return new \"+c+\"(this.data,\"+Z.join(\",\")+\",\"+R.join(\",\")+\",this.offset)}\"),f.push(\"proto.pick=function \"+c+\"_pick(\"+M+\"){var a=[],b=[],c=this.offset\");for(var i=0;i<h;++i)f.push(\"if(typeof i\"+i+\"==='number'&&i\"+i+\">=0){c=(c+this.stride[\"+i+\"]*i\"+i+\")|0}else{a.push(this.shape[\"+i+\"]);b.push(this.stride[\"+i+\"])}\");f.push(\"var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}\"),f.push(\"return function construct_\"+c+\"(data,shape,stride,offset){return new \"+c+\"(data,\"+d.map(function(p){return\"shape[\"+p+\"]\"}).join(\",\")+\",\"+d.map(function(p){return\"stride[\"+p+\"]\"}).join(\",\")+\",offset)}\");var O=new Function(\"CTOR_LIST\",\"ORDER\",f.join(`\n",
              "`));return O(u[l],m)}function C(l){if(n(l))return\"buffer\";if(g)switch(Object.prototype.toString.call(l)){case\"[object Float64Array]\":return\"float64\";case\"[object Float32Array]\":return\"float32\";case\"[object Int8Array]\":return\"int8\";case\"[object Int16Array]\":return\"int16\";case\"[object Int32Array]\":return\"int32\";case\"[object Uint8Array]\":return\"uint8\";case\"[object Uint16Array]\":return\"uint16\";case\"[object Uint32Array]\":return\"uint32\";case\"[object Uint8ClampedArray]\":return\"uint8_clamped\";case\"[object BigInt64Array]\":return\"bigint64\";case\"[object BigUint64Array]\":return\"biguint64\"}return Array.isArray(l)?\"array\":\"generic\"}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function v(l,h,c,N){if(l===void 0){var D=u.array[0];return D([])}else typeof l==\"number\"&&(l=[l]);h===void 0&&(h=[l.length]);var f=h.length;if(c===void 0){c=new Array(f);for(var d=f-1,M=1;d>=0;--d)c[d]=M,M*=h[d]}if(N===void 0){N=0;for(var d=0;d<f;++d)c[d]<0&&(N-=(h[d]-1)*c[d])}for(var L=C(l),j=u[L];j.length<=f+1;)j.push(_(L,j.length-1));var D=j[f+1];return D(l,h,c,N)}k.exports=v},829:(k,I)=>{\"use strict\";var E;E={value:!0},I.g=m;function T(u,v){if(!(u instanceof v))throw new TypeError(\"Cannot call a class as a function\")}function n(u,v){for(var l,h=0;h<v.length;h++)l=v[h],l.enumerable=l.enumerable||!1,l.configurable=!0,\"value\"in l&&(l.writable=!0),Object.defineProperty(u,l.key,l)}function g(u,v,l){return v&&n(u.prototype,v),l&&n(u,l),u}var s=function(){function u(v){T(this,u),v instanceof DataView?this.dataView=v:v instanceof ArrayBuffer&&(this.dataView=new DataView(v)),this.offset=0}return g(u,[{key:\"readBytes\",value:function(l){var h=new DataView(this.dataView.buffer,this.offset,l);return this.offset+=l,h}},{key:\"readAndASCIIDecodeBytes\",value:function(l){var h=new Uint8Array(this.dataView.buffer,this.offset,l);return this.offset+=l,this._decodeASCIIByteArray(h)}},{key:\"readUint8\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint8(this.offset,l);return this.offset+=Uint8Array.BYTES_PER_ELEMENT,h}},{key:\"readUint16\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint16(this.offset,l);return this.offset+=Uint16Array.BYTES_PER_ELEMENT,h}},{key:\"readUint32\",value:function(){var l=0<arguments.length&&arguments[0]!==void 0&&arguments[0],h=this.dataView.getUint32(this.offset,l);return this.offset+=Uint32Array.BYTES_PER_ELEMENT,h}},{key:\"_decodeASCIIByteArray\",value:function(l){var h=String.fromCharCode,c=[],N=!0,f=!1,d=void 0;try{for(var M,L=l[Symbol.iterator]();!(N=(M=L.next()).done);N=!0){var j=M.value,D=h(j);c.push(D)}}catch(A){f=!0,d=A}finally{try{N||L.return==null||L.return()}finally{if(f)throw d}}return c.join(\"\")}}]),u}();function m(u){if(!u instanceof ArrayBuffer)throw new Error(\"Argument must be an ArrayBuffer.\");var v=new s(u),l=v.readUint8(),h=v.readAndASCIIDecodeBytes(5);if(l!=147||h!=\"NUMPY\")throw new Error('unknown file type: \"'.concat(l).concat(h,'\"'));var c,N=v.readUint8(),f=v.readUint8();c=1>=N?v.readUint16(!0):v.readUint32(!0);var d=10+c;d%16!=0&&console.warn(\"NPY file header is incorrectly padded. (\".concat(d,\" is not evenly divisible by 16.)\"));var M=v.readAndASCIIDecodeBytes(c),L=_(M);if(L.fortran_order)throw new Error(\"NPY file is written in Fortran byte order, support for this byte order is not yet implemented.\");var j=C(L.descr),D=new j(u,v.offset);return{data:D,shape:L.shape}}function _(u){var v=u.toLowerCase().replace(\"(\",\"[\").replace(\"),\",\"]\").replace(\"[,\",\"[1,]\").replace(\",]\",\",1]\").replace(/'/g,'\"');return JSON.parse(v)}function C(u){switch(u){case\"|u1\":return Uint8Array;case\"<u2\":return Uint16Array;case\"<u4\":return Uint32Array;case\"<u8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit unsigned integer values, support for this dtype is not yet implemented.\");case\"|i1\":return Int8Array;case\"<i2\":return Int16Array;case\"<i4\":return Int32Array;case\"<i8\":throw new Error(\"Because JavaScript doesn't currently include standard support for 64-bit integer values, support for this dtype is not yet implemented.\");case\"<f2\":throw new Error(\"Because JavaScript doesn't currently include standard support for 16-bit floating point values, support for this dtype is not yet implemented.\");case\"<f4\":return Float32Array;case\"<f8\":return Float64Array;default:throw new Error(\"Unknown or not yet implemented numpy dtype description: \"+dtype)}}},843:(k,I,E)=>{\"use strict\";var T;const n=E(948),g=E(236),s=E(373),m=E(898),_=E(292),C=E(401),u=Object.prototype.toString,{Z_NO_FLUSH:v,Z_FINISH:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M}=E(619);function L(A){this.options=g.assign({chunkSize:65536,windowBits:15,to:\"\"},A||{});const o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(A&&A.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15)===0&&(o.windowBits|=15),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,o.windowBits);if(i!==h)throw new Error(m[i]);if(this.header=new C,n.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==\"string\"?o.dictionary=s.string2buf(o.dictionary):u.call(o.dictionary)===\"[object ArrayBuffer]\"&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(i=n.inflateSetDictionary(this.strm,o.dictionary),i!==h)))throw new Error(m[i])}L.prototype.push=function(A,o){const i=this.strm,Z=this.options.chunkSize,R=this.options.dictionary;let O,p,U;if(this.ended)return!1;for(o===~~o?p=o:p=o===!0?l:v,u.call(A)===\"[object ArrayBuffer]\"?i.input=new Uint8Array(A):i.input=A,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(Z),i.next_out=0,i.avail_out=Z),O=n.inflate(i,p),O===N&&R&&(O=n.inflateSetDictionary(i,R),O===h?O=n.inflate(i,p):O===d&&(O=N));i.avail_in>0&&O===c&&i.state.wrap>0&&A[i.next_in]!==0;)n.inflateReset(i),O=n.inflate(i,p);switch(O){case f:case d:case N:case M:return this.onEnd(O),this.ended=!0,!1}if(U=i.avail_out,i.next_out&&(i.avail_out===0||O===c))if(this.options.to===\"string\"){let B=s.utf8border(i.output,i.next_out),K=i.next_out-B,V=s.buf2string(i.output,B);i.next_out=K,i.avail_out=Z-K,K&&i.output.set(i.output.subarray(B,B+K),0),this.onData(V)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(O===h&&U===0)){if(O===c)return O=n.inflateEnd(this.strm),this.onEnd(O),this.ended=!0,!0;if(i.avail_in===0)break}}return!0},L.prototype.onData=function(A){this.chunks.push(A)},L.prototype.onEnd=function(A){A===h&&(this.options.to===\"string\"?this.result=this.chunks.join(\"\"):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};function j(A,o){const i=new L(o);if(i.push(A),i.err)throw i.msg||m[i.err];return i.result}function D(A,o){return o=o||{},o.raw=!0,j(A,o)}T=L,k.exports.rr=j,T=D,T=j,E(619)},236:k=>{\"use strict\";const I=(E,T)=>Object.prototype.hasOwnProperty.call(E,T);k.exports.assign=function(E){const T=Array.prototype.slice.call(arguments,1);for(;T.length;){const n=T.shift();if(!!n){if(typeof n!=\"object\")throw new TypeError(n+\"must be non-object\");for(const g in n)I(n,g)&&(E[g]=n[g])}}return E},k.exports.flattenChunks=E=>{let T=0;for(let g=0,s=E.length;g<s;g++)T+=E[g].length;const n=new Uint8Array(T);for(let g=0,s=0,m=E.length;g<m;g++){let _=E[g];n.set(_,s),s+=_.length}return n}},373:k=>{\"use strict\";let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){I=!1}const E=new Uint8Array(256);for(let n=0;n<256;n++)E[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;E[254]=E[254]=1,k.exports.string2buf=n=>{let g,s,m,_,C,u=n.length,v=0;for(_=0;_<u;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),v+=s<128?1:s<2048?2:s<65536?3:4;for(g=new Uint8Array(v),C=0,_=0;C<v;_++)s=n.charCodeAt(_),(s&64512)===55296&&_+1<u&&(m=n.charCodeAt(_+1),(m&64512)===56320&&(s=65536+(s-55296<<10)+(m-56320),_++)),s<128?g[C++]=s:s<2048?(g[C++]=192|s>>>6,g[C++]=128|s&63):s<65536?(g[C++]=224|s>>>12,g[C++]=128|s>>>6&63,g[C++]=128|s&63):(g[C++]=240|s>>>18,g[C++]=128|s>>>12&63,g[C++]=128|s>>>6&63,g[C++]=128|s&63);return g};const T=(n,g)=>{if(g<65534&&n.subarray&&I)return String.fromCharCode.apply(null,n.length===g?n:n.subarray(0,g));let s=\"\";for(let m=0;m<g;m++)s+=String.fromCharCode(n[m]);return s};k.exports.buf2string=(n,g)=>{let s,m;const _=g||n.length,C=new Array(_*2);for(m=0,s=0;s<_;){let u=n[s++];if(u<128){C[m++]=u;continue}let v=E[u];if(v>4){C[m++]=65533,s+=v-1;continue}for(u&=v===2?31:v===3?15:7;v>1&&s<_;)u=u<<6|n[s++]&63,v--;if(v>1){C[m++]=65533;continue}u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|u&1023)}return T(C,m)},k.exports.utf8border=(n,g)=>{g=g||n.length,g>n.length&&(g=n.length);let s=g-1;for(;s>=0&&(n[s]&192)===128;)s--;return s<0||s===0?g:s+E[n[s]]>g?s:g}},69:k=>{\"use strict\";const I=(E,T,n,g)=>{let s=E&65535|0,m=E>>>16&65535|0,_=0;for(;n!==0;){_=n>2e3?2e3:n,n-=_;do s=s+T[g++]|0,m=m+s|0;while(--_);s%=65521,m%=65521}return s|m<<16|0};k.exports=I},619:k=>{\"use strict\";k.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:k=>{\"use strict\";const I=()=>{let n,g=[];for(var s=0;s<256;s++){n=s;for(var m=0;m<8;m++)n=n&1?3988292384^n>>>1:n>>>1;g[s]=n}return g},E=new Uint32Array(I()),T=(n,g,s,m)=>{const _=E,C=m+s;n^=-1;for(let u=m;u<C;u++)n=n>>>8^_[(n^g[u])&255];return n^-1};k.exports=T},401:k=>{\"use strict\";function I(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}k.exports=I},264:k=>{\"use strict\";k.exports=function(n,g){let s,m,_,C,u,v,l,h,c,N,f,d,M,L,j,D,A,o,i,Z,R,O,p,U;const B=n.state;s=n.next_in,p=n.input,m=s+(n.avail_in-5),_=n.next_out,U=n.output,C=_-(g-n.avail_out),u=_+(n.avail_out-257),v=B.dmax,l=B.wsize,h=B.whave,c=B.wnext,N=B.window,f=B.hold,d=B.bits,M=B.lencode,L=B.distcode,j=(1<<B.lenbits)-1,D=(1<<B.distbits)-1;e:do{d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=M[f&j];t:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o===0)U[_++]=A&65535;else if(o&16){i=A&65535,o&=15,o&&(d<o&&(f+=p[s++]<<d,d+=8),i+=f&(1<<o)-1,f>>>=o,d-=o),d<15&&(f+=p[s++]<<d,d+=8,f+=p[s++]<<d,d+=8),A=L[f&D];i:for(;;){if(o=A>>>24,f>>>=o,d-=o,o=A>>>16&255,o&16){if(Z=A&65535,o&=15,d<o&&(f+=p[s++]<<d,d+=8,d<o&&(f+=p[s++]<<d,d+=8)),Z+=f&(1<<o)-1,Z>v){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(f>>>=o,d-=o,o=_-C,Z>o){if(o=Z-o,o>h&&B.sane){n.msg=\"invalid distance too far back\",B.mode=30;break e}if(R=0,O=N,c===0){if(R+=l-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}else if(c<o){if(R+=l+c-o,o-=c,o<i){i-=o;do U[_++]=N[R++];while(--o);if(R=0,c<i){o=c,i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}}}else if(R+=c-o,o<i){i-=o;do U[_++]=N[R++];while(--o);R=_-Z,O=U}for(;i>2;)U[_++]=O[R++],U[_++]=O[R++],U[_++]=O[R++],i-=3;i&&(U[_++]=O[R++],i>1&&(U[_++]=O[R++]))}else{R=_-Z;do U[_++]=U[R++],U[_++]=U[R++],U[_++]=U[R++],i-=3;while(i>2);i&&(U[_++]=U[R++],i>1&&(U[_++]=U[R++]))}}else if((o&64)===0){A=L[(A&65535)+(f&(1<<o)-1)];continue i}else{n.msg=\"invalid distance code\",B.mode=30;break e}break}}else if((o&64)===0){A=M[(A&65535)+(f&(1<<o)-1)];continue t}else if(o&32){B.mode=12;break e}else{n.msg=\"invalid literal/length code\",B.mode=30;break e}break}}while(s<m&&_<u);i=d>>3,s-=i,d-=i<<3,f&=(1<<d)-1,n.next_in=s,n.next_out=_,n.avail_in=s<m?5+(m-s):5-(s-m),n.avail_out=_<u?257+(u-_):257-(_-u),B.hold=f,B.bits=d}},948:(k,I,E)=>{\"use strict\";const T=E(69),n=E(869),g=E(264),s=E(241),m=0,_=1,C=2,{Z_FINISH:u,Z_BLOCK:v,Z_TREES:l,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:N,Z_STREAM_ERROR:f,Z_DATA_ERROR:d,Z_MEM_ERROR:M,Z_BUF_ERROR:L,Z_DEFLATED:j}=E(619),D=1,A=2,o=3,i=4,Z=5,R=6,O=7,p=8,U=9,B=10,K=11,V=12,fe=13,de=14,ne=15,ce=16,pe=17,le=18,te=19,re=20,ae=21,we=22,_e=23,ue=24,he=25,Te=26,ke=27,Oe=28,De=29,F=30,Ee=31,Pe=32,Fe=852,je=592,He=15,Re=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ze(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ie=t=>{if(!t||!t.state)return f;const x=t.state;return t.total_in=t.total_out=x.total=0,t.msg=\"\",x.wrap&&(t.adler=x.wrap&1),x.mode=D,x.last=0,x.havedict=0,x.dmax=32768,x.head=null,x.hold=0,x.bits=0,x.lencode=x.lendyn=new Int32Array(Fe),x.distcode=x.distdyn=new Int32Array(je),x.sane=1,x.back=-1,h},Ue=t=>{if(!t||!t.state)return f;const x=t.state;return x.wsize=0,x.whave=0,x.wnext=0,Ie(t)},Ce=(t,x)=>{let e;if(!t||!t.state)return f;const y=t.state;return x<0?(e=0,x=-x):(e=(x>>4)+1,x<48&&(x&=15)),x&&(x<8||x>15)?f:(y.window!==null&&y.wbits!==x&&(y.window=null),y.wrap=e,y.wbits=x,Ue(t))},Ne=(t,x)=>{if(!t)return f;const e=new ze;t.state=e,e.window=null;const y=Ce(t,x);return y!==h&&(t.state=null),y},Ye=t=>Ne(t,He);let Be=!0,Ae,Se;const Ge=t=>{if(Be){Ae=new Int32Array(512),Se=new Int32Array(32);let x=0;for(;x<144;)t.lens[x++]=8;for(;x<256;)t.lens[x++]=9;for(;x<280;)t.lens[x++]=7;for(;x<288;)t.lens[x++]=8;for(s(_,t.lens,0,288,Ae,0,t.work,{bits:9}),x=0;x<32;)t.lens[x++]=5;s(C,t.lens,0,32,Se,0,t.work,{bits:5}),Be=!1}t.lencode=Ae,t.lenbits=9,t.distcode=Se,t.distbits=5},Me=(t,x,e,y)=>{let H;const w=t.state;return w.window===null&&(w.wsize=1<<w.wbits,w.wnext=0,w.whave=0,w.window=new Uint8Array(w.wsize)),y>=w.wsize?(w.window.set(x.subarray(e-w.wsize,e),0),w.wnext=0,w.whave=w.wsize):(H=w.wsize-w.wnext,H>y&&(H=y),w.window.set(x.subarray(e-y,e-y+H),w.wnext),y-=H,y?(w.window.set(x.subarray(e-y,e),0),w.wnext=y,w.whave=w.wsize):(w.wnext+=H,w.wnext===w.wsize&&(w.wnext=0),w.whave<w.wsize&&(w.whave+=H))),0},Xe=(t,x)=>{let e,y,H,w,q,b,G,a,r,xe,z,S,be,me,Y=0,P,J,$,Q,ve,ge,X,ee;const W=new Uint8Array(4);let oe,ie;const Le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return f;e=t.state,e.mode===V&&(e.mode=fe),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,xe=b,z=G,ee=h;e:for(;;)switch(e.mode){case D:if(e.wrap===0){e.mode=fe;break}for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.wrap&2&&a===35615){e.check=0,W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0),a=0,r=0,e.mode=A;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((a&255)<<8)+(a>>8))%31){t.msg=\"incorrect header check\",e.mode=F;break}if((a&15)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(a>>>=4,r-=4,X=(a&15)+8,e.wbits===0)e.wbits=X;else if(X>e.wbits){t.msg=\"invalid window size\",e.mode=F;break}e.dmax=1<<e.wbits,t.adler=e.check=1,e.mode=a&512?B:V,a=0,r=0;break;case A:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.flags=a,(e.flags&255)!==j){t.msg=\"unknown compression method\",e.mode=F;break}if(e.flags&57344){t.msg=\"unknown header flags set\",e.mode=F;break}e.head&&(e.head.text=a>>8&1),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=o;case o:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.time=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,W[2]=a>>>16&255,W[3]=a>>>24&255,e.check=n(e.check,W,4,0)),a=0,r=0,e.mode=i;case i:for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.head&&(e.head.xflags=a&255,e.head.os=a>>8),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0,e.mode=Z;case Z:if(e.flags&1024){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length=a,e.head&&(e.head.extra_len=a),e.flags&512&&(W[0]=a&255,W[1]=a>>>8&255,e.check=n(e.check,W,2,0)),a=0,r=0}else e.head&&(e.head.extra=null);e.mode=R;case R:if(e.flags&1024&&(S=e.length,S>b&&(S=b),S&&(e.head&&(X=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(y.subarray(w,w+S),X)),e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,e.length-=S),e.length))break e;e.length=0,e.mode=O;case O:if(e.flags&2048){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.name+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=p;case p:if(e.flags&4096){if(b===0)break e;S=0;do X=y[w+S++],e.head&&X&&e.length<65536&&(e.head.comment+=String.fromCharCode(X));while(X&&S<b);if(e.flags&512&&(e.check=n(e.check,y,S,w)),b-=S,w+=S,X)break e}else e.head&&(e.head.comment=null);e.mode=U;case U:if(e.flags&512){for(;r<16;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.check&65535)){t.msg=\"header crc mismatch\",e.mode=F;break}a=0,r=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),t.adler=e.check=0,e.mode=V;break;case B:for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}t.adler=e.check=Re(a),a=0,r=0,e.mode=K;case K:if(e.havedict===0)return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,N;t.adler=e.check=1,e.mode=V;case V:if(x===v||x===l)break e;case fe:if(e.last){a>>>=r&7,r-=r&7,e.mode=ke;break}for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}switch(e.last=a&1,a>>>=1,r-=1,a&3){case 0:e.mode=de;break;case 1:if(Ge(e),e.mode=re,x===l){a>>>=2,r-=2;break e}break;case 2:e.mode=pe;break;case 3:t.msg=\"invalid block type\",e.mode=F}a>>>=2,r-=2;break;case de:for(a>>>=r&7,r-=r&7;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((a&65535)!==(a>>>16^65535)){t.msg=\"invalid stored block lengths\",e.mode=F;break}if(e.length=a&65535,a=0,r=0,e.mode=ne,x===l)break e;case ne:e.mode=ce;case ce:if(S=e.length,S){if(S>b&&(S=b),S>G&&(S=G),S===0)break e;H.set(y.subarray(w,w+S),q),b-=S,w+=S,G-=S,q+=S,e.length-=S;break}e.mode=V;break;case pe:for(;r<14;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(e.nlen=(a&31)+257,a>>>=5,r-=5,e.ndist=(a&31)+1,a>>>=5,r-=5,e.ncode=(a&15)+4,a>>>=4,r-=4,e.nlen>286||e.ndist>30){t.msg=\"too many length or distance symbols\",e.mode=F;break}e.have=0,e.mode=le;case le:for(;e.have<e.ncode;){for(;r<3;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.lens[Le[e.have++]]=a&7,a>>>=3,r-=3}for(;e.have<19;)e.lens[Le[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,oe={bits:e.lenbits},ee=s(m,e.lens,0,19,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid code lengths set\",e.mode=F;break}e.have=0,e.mode=te;case te:for(;e.have<e.nlen+e.ndist;){for(;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if($<16)a>>>=P,r-=P,e.lens[e.have++]=$;else{if($===16){for(ie=P+2;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a>>>=P,r-=P,e.have===0){t.msg=\"invalid bit length repeat\",e.mode=F;break}X=e.lens[e.have-1],S=3+(a&3),a>>>=2,r-=2}else if($===17){for(ie=P+3;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=3+(a&7),a>>>=3,r-=3}else{for(ie=P+7;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=P,r-=P,X=0,S=11+(a&127),a>>>=7,r-=7}if(e.have+S>e.nlen+e.ndist){t.msg=\"invalid bit length repeat\",e.mode=F;break}for(;S--;)e.lens[e.have++]=X}}if(e.mode===F)break;if(e.lens[256]===0){t.msg=\"invalid code -- missing end-of-block\",e.mode=F;break}if(e.lenbits=9,oe={bits:e.lenbits},ee=s(_,e.lens,0,e.nlen,e.lencode,0,e.work,oe),e.lenbits=oe.bits,ee){t.msg=\"invalid literal/lengths set\",e.mode=F;break}if(e.distbits=6,e.distcode=e.distdyn,oe={bits:e.distbits},ee=s(C,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,oe),e.distbits=oe.bits,ee){t.msg=\"invalid distances set\",e.mode=F;break}if(e.mode=re,x===l)break e;case re:e.mode=ae;case ae:if(b>=6&&G>=258){t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,g(t,z),q=t.next_out,H=t.output,G=t.avail_out,w=t.next_in,y=t.input,b=t.avail_in,a=e.hold,r=e.bits,e.mode===V&&(e.back=-1);break}for(e.back=0;Y=e.lencode[a&(1<<e.lenbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(J&&(J&240)===0){for(Q=P,ve=J,ge=$;Y=e.lencode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,e.length=$,J===0){e.mode=Te;break}if(J&32){e.back=-1,e.mode=V;break}if(J&64){t.msg=\"invalid literal/length code\",e.mode=F;break}e.extra=J&15,e.mode=we;case we:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.length+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=_e;case _e:for(;Y=e.distcode[a&(1<<e.distbits)-1],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if((J&240)===0){for(Q=P,ve=J,ge=$;Y=e.distcode[ge+((a&(1<<Q+ve)-1)>>Q)],P=Y>>>24,J=Y>>>16&255,$=Y&65535,!(Q+P<=r);){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}a>>>=Q,r-=Q,e.back+=Q}if(a>>>=P,r-=P,e.back+=P,J&64){t.msg=\"invalid distance code\",e.mode=F;break}e.offset=$,e.extra=J&15,e.mode=ue;case ue:if(e.extra){for(ie=e.extra;r<ie;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}e.offset+=a&(1<<e.extra)-1,a>>>=e.extra,r-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){t.msg=\"invalid distance too far back\",e.mode=F;break}e.mode=he;case he:if(G===0)break e;if(S=z-G,e.offset>S){if(S=e.offset-S,S>e.whave&&e.sane){t.msg=\"invalid distance too far back\",e.mode=F;break}S>e.wnext?(S-=e.wnext,be=e.wsize-S):be=e.wnext-S,S>e.length&&(S=e.length),me=e.window}else me=H,be=q-e.offset,S=e.length;S>G&&(S=G),G-=S,e.length-=S;do H[q++]=me[be++];while(--S);e.length===0&&(e.mode=ae);break;case Te:if(G===0)break e;H[q++]=e.length,G--,e.mode=ae;break;case ke:if(e.wrap){for(;r<32;){if(b===0)break e;b--,a|=y[w++]<<r,r+=8}if(z-=G,t.total_out+=z,e.total+=z,z&&(t.adler=e.check=e.flags?n(e.check,H,z,q-z):T(e.check,H,z,q-z)),z=G,(e.flags?a:Re(a))!==e.check){t.msg=\"incorrect data check\",e.mode=F;break}a=0,r=0}e.mode=Oe;case Oe:if(e.wrap&&e.flags){for(;r<32;){if(b===0)break e;b--,a+=y[w++]<<r,r+=8}if(a!==(e.total&4294967295)){t.msg=\"incorrect length check\",e.mode=F;break}a=0,r=0}e.mode=De;case De:ee=c;break e;case F:ee=d;break e;case Ee:return M;case Pe:default:return f}return t.next_out=q,t.avail_out=G,t.next_in=w,t.avail_in=b,e.hold=a,e.bits=r,(e.wsize||z!==t.avail_out&&e.mode<F&&(e.mode<ke||x!==u))&&Me(t,t.output,t.next_out,z-t.avail_out)?(e.mode=Ee,M):(xe-=t.avail_in,z-=t.avail_out,t.total_in+=xe,t.total_out+=z,e.total+=z,e.wrap&&z&&(t.adler=e.check=e.flags?n(e.check,H,z,t.next_out-z):T(e.check,H,z,t.next_out-z)),t.data_type=e.bits+(e.last?64:0)+(e.mode===V?128:0)+(e.mode===re||e.mode===ne?256:0),(xe===0&&z===0||x===u)&&ee===h&&(ee=L),ee)},Ke=t=>{if(!t||!t.state)return f;let x=t.state;return x.window&&(x.window=null),t.state=null,h},Ve=(t,x)=>{if(!t||!t.state)return f;const e=t.state;return(e.wrap&2)===0?f:(e.head=x,x.done=!1,h)},We=(t,x)=>{const e=x.length;let y,H,w;return!t||!t.state||(y=t.state,y.wrap!==0&&y.mode!==K)?f:y.mode===K&&(H=1,H=T(H,x,e,0),H!==y.check)?d:(w=Me(t,x,e,e),w?(y.mode=Ee,M):(y.havedict=1,h))};k.exports.inflateReset=Ue,k.exports.inflateReset2=Ce,k.exports.inflateResetKeep=Ie,k.exports.inflateInit=Ye,k.exports.inflateInit2=Ne,k.exports.inflate=Xe,k.exports.inflateEnd=Ke,k.exports.inflateGetHeader=Ve,k.exports.inflateSetDictionary=We,k.exports.inflateInfo=\"pako inflate (from Nodeca project)\"},241:k=>{\"use strict\";const m=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),C=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),u=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),v=(l,h,c,N,f,d,M,L)=>{const j=L.bits;let D=0,A=0,o=0,i=0,Z=0,R=0,O=0,p=0,U=0,B=0,K,V,fe,de,ne,ce=null,pe=0,le;const te=new Uint16Array(15+1),re=new Uint16Array(15+1);let ae=null,we=0,_e,ue,he;for(D=0;D<=15;D++)te[D]=0;for(A=0;A<N;A++)te[h[c+A]]++;for(Z=j,i=15;i>=1&&te[i]===0;i--);if(Z>i&&(Z=i),i===0)return f[d++]=1<<24|64<<16|0,f[d++]=1<<24|64<<16|0,L.bits=1,0;for(o=1;o<i&&te[o]===0;o++);for(Z<o&&(Z=o),p=1,D=1;D<=15;D++)if(p<<=1,p-=te[D],p<0)return-1;if(p>0&&(l===0||i!==1))return-1;for(re[1]=0,D=1;D<15;D++)re[D+1]=re[D]+te[D];for(A=0;A<N;A++)h[c+A]!==0&&(M[re[h[c+A]]++]=A);if(l===0?(ce=ae=M,le=19):l===1?(ce=m,pe-=257,ae=_,we-=257,le=256):(ce=C,ae=u,le=-1),B=0,A=0,D=o,ne=d,R=Z,O=0,fe=-1,U=1<<Z,de=U-1,l===1&&U>852||l===2&&U>592)return 1;for(;;){_e=D-O,M[A]<le?(ue=0,he=M[A]):M[A]>le?(ue=ae[we+M[A]],he=ce[pe+M[A]]):(ue=32+64,he=0),K=1<<D-O,V=1<<R,o=V;do V-=K,f[ne+(B>>O)+V]=_e<<24|ue<<16|he|0;while(V!==0);for(K=1<<D-1;B&K;)K>>=1;if(K!==0?(B&=K-1,B+=K):B=0,A++,--te[D]===0){if(D===i)break;D=h[c+M[A]]}if(D>Z&&(B&de)!==fe){for(O===0&&(O=Z),ne+=o,R=D-O,p=1<<R;R+O<i&&(p-=te[R+O],!(p<=0));)R++,p<<=1;if(U+=1<<R,l===1&&U>852||l===2&&U>592)return 1;fe=B&de,f[fe]=Z<<24|R<<16|ne-d|0}}return B!==0&&(f[ne+B]=D-O<<24|64<<16|0),L.bits=Z,0};k.exports=v},898:k=>{\"use strict\";k.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},292:k=>{\"use strict\";function I(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}k.exports=I},330:(k,I,E)=>{\"use strict\";E.d(I,{default:()=>C});var T=E(829),n=E(861),g=E.n(n),s=E(843);function m(u){if(u.__type__==\"npy\"){var v;if(window.obj=u,u.hasOwnProperty(\"zdata\")){const f=Uint8Array.from(window.atob(u.zdata),d=>d.charCodeAt(0));v=(0,s.rr)(f)}else v=Uint8Array.from(window.atob(u.data),f=>f.charCodeAt(0));var l=(0,T.g)(v.buffer);if(l=n(l.data,l.shape),u.hasOwnProperty(\"min\")){let f=l.dtype===\"uint8\"?255:65535;for(var h=1,c=0;c<l.shape.length;c++)h=h*l.shape[c];for(var N=n(new Float32Array(h),l.shape),c=0;c<l.data.length;c++)N.data[c]=u.min+(u.max-u.min)*l.data[c]/f;return N}else return l}else return{}}function _(u){if(Array.isArray(u)){var v=[];for(var l of u)v.push(_(l));return v}else if(u instanceof Object){if(u.hasOwnProperty(\"__type__\"))return m(u);var v={};for(var h of Object.keys(u))v[h]=_(u[h]);return v}else return u}const C=loader={unpack_obj:_}}},ye={};function se(k){if(ye[k])return ye[k].exports;var I=ye[k]={exports:{}};return Ze[k](I,I.exports,se),I.exports}return se.n=k=>{var I=k&&k.__esModule?()=>k.default:()=>k;return se.d(I,{a:I}),I},se.d=(k,I)=>{for(var E in I)se.o(I,E)&&!se.o(k,E)&&Object.defineProperty(k,E,{enumerable:!0,get:I[E]})},se.o=(k,I)=>Object.prototype.hasOwnProperty.call(k,I),se(330)})().default;\n",
              "</script>\n",
              "        \n",
              "        <div id=\"AttentionMulti_3d5f764\"></div>\n",
              "        <script>\n",
              "        ( () => {\n",
              "            var data = {\n",
              "\"tokens\": [\n",
              "\"<|endoftext|>\",\n",
              "\"The\",\n",
              "\" following\",\n",
              "\" lex\",\n",
              "\"ical\",\n",
              "\" sequence\",\n",
              "\" has\",\n",
              "\" been\",\n",
              "\" optim\",\n",
              "\"ised\",\n",
              "\" for\",\n",
              "\" the\",\n",
              "\" maxim\",\n",
              "\"isation\",\n",
              "\" of\",\n",
              "\" lo\",\n",
              "\"qu\",\n",
              "\"aciously\",\n",
              "\" multit\",\n",
              "\"oken\",\n",
              "\" letter\",\n",
              "\" combinations\",\n",
              "\".\"\n",
              "],\n",
              "\"attention\": {\n",
              "\"__type__\": \"npy\",\n",
              "\"zdata\": \"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\",\n",
              "\"min\": 0.0,\n",
              "\"max\": 1.0\n",
              "}\n",
              "};\n",
              "            data = loader.unpack_obj(data);\n",
              "            window.AttentionMulti_data = data;\n",
              "            var AttentionMulti_inst = new AttentionMulti({\n",
              "                \"target\": document.getElementById(\"AttentionMulti_3d5f764\"),\n",
              "                \"props\": data\n",
              "                });\n",
              "        })();\n",
              "        </script>\n",
              "        \n",
              "        "
            ],
            "text/plain": [
              "<pysvelte.html.Html at 0x7f7028a7a200>"
            ]
          },
          "execution_count": 22,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "plot_attn_pattern_from_cache(cache, 0)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TMwvCbW-Rae_"
      },
      "source": [
        "As we can see, L5H6 appears to be doing something totally different than we expected, whereas L0H3 is mostly doing what we expected - by our original hypothesis, we would expect \"lo|qu|aciously\" to have a lot of attention paid to, and \"combinations|.\" the same, which didn't happen. However, our two-token words were exactly as we expected. Could this be a two-token detector (that doesn't work on punctuation)? A \"current word\" detector that just doesn't understand an obscure word like \"loquaciously\"? The field is full of such problems, just waiting to be answered!\n",
        "\n",
        "So, why do this at all? For just a couple of sentences, it's easier to just look at the attention patterns directly and see what we get. But as we can see, heads react differently to different sentences. What we might want to do is give an entire dataset or distribution of sentences to our attention head and see that it consistently does what we want - that's something that would be much harder without this feature!\n",
        "\n",
        "So what if we gave it a whole distribution? Rather than actually create one, which is not the point of this demo, we're just going to repeat our last sentence a thousand times."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 23,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 560
        },
        "id": "LrgxDy7C7p-n",
        "outputId": "fa0983a4-1d67-4903-a73a-2c09bbc891a7"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "100%|██████████| 100/100 [00:13<00:00,  7.64it/s]\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"7b68e978-d5ba-4c14-9c22-7a8234a56535\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"7b68e978-d5ba-4c14-9c22-7a8234a56535\")) {                    Plotly.newPlot(                        \"7b68e978-d5ba-4c14-9c22-7a8234a56535\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[-0.16099999845027924,0.6179999709129333,-0.2420000582933426,0.7519999742507935,0.5019999146461487,0.5270000100135803,-0.1080000177025795,0.16199997067451477,-0.12399997562170029,-0.22300003468990326,-0.06700002402067184,-0.1889999806880951],[0.06700002402067184,-0.12600001692771912,-0.1289999634027481,-0.18000003695487976,-0.16599997878074646,-0.18400000035762787,-0.03500000014901161,-0.2239999920129776,-0.22200003266334534,-0.2550000846385956,-0.03200000151991844,0.4200000464916229],[-0.1080000177025795,-0.24900002777576447,0.2590000331401825,-0.07200001925230026,0.09399999678134918,-0.11399998515844345,-0.19499996304512024,-0.0689999982714653,-0.11999998986721039,0.004000000189989805,-0.07500000298023224,-0.2069999873638153],[-0.23199991881847382,-0.22300003468990326,-0.03999999910593033,0.08500000089406967,-0.2930000424385071,-0.25600001215934753,0.0950000211596489,0.009999999776482582,-0.15000000596046448,-0.14899998903274536,-0.11899998039007187,-0.05000000447034836],[-0.10099997371435165,-0.1900000423192978,-0.26900002360343933,-0.12800000607967377,-0.2370000034570694,-0.1289999634027481,-0.21699999272823334,0.27500006556510925,-0.27500006556510925,-0.2330000102519989,-0.28200003504753113,0.3039999306201935],[-0.2630000114440918,-0.3020000159740448,-0.18400000035762787,-0.23600004613399506,-0.2149999588727951,-0.2839999496936798,-0.19700001180171967,-0.17000000178813934,-0.2529999911785126,-0.28800007700920105,-0.1599999964237213,-0.19700001180171967],[-0.23799996078014374,-0.2420000582933426,-0.28600001335144043,-0.2839999496936798,-0.19499996304512024,-0.22200003266334534,-0.22099998593330383,-0.2030000239610672,-0.04600000008940697,-0.2919999957084656,-0.28800007700920105,-0.2149999588727951],[-0.2449999302625656,-0.25,-0.30100008845329285,-0.23499993979930878,-0.273999959230423,-0.2680000960826874,-0.27699998021125793,-0.2919999957084656,-0.19899997115135193,-0.2590000331401825,-0.2969999611377716,-0.2930000424385071],[-0.2529999911785126,-0.29600000381469727,-0.23499993979930878,-0.2669999897480011,-0.1889999806880951,-0.25099995732307434,-0.2759999930858612,-0.2069999873638153,-0.1940000206232071,-0.2199999988079071,-0.2290000468492508,-0.270999938249588],[-0.22099998593330383,-0.2919999957084656,-0.2630000114440918,-0.16700002551078796,-0.2909999191761017,-0.270999938249588,-0.28800007700920105,-0.28299999237060547,-0.27000001072883606,-0.28700000047683716,-0.24399997293949127,-0.29899996519088745],[-0.2669999897480011,-0.27900001406669617,-0.28200003504753113,-0.2630000114440918,-0.23499993979930878,-0.26900002360343933,-0.270999938249588,-0.24799995124340057,-0.28700000047683716,-0.15599998831748962,-0.2720000445842743,-0.24799999594688416],[-0.14800000190734863,-0.25600001215934753,-0.26900002360343933,-0.24399997293949127,-0.2370000034570694,-0.2720000445842743,-0.27799996733665466,-0.2579999566078186,-0.06599999219179153,-0.2759999930858612,-0.20900003612041473,-0.22600002586841583]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Current Word Head Matches\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('7b68e978-d5ba-4c14-9c22-7a8234a56535');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "scores = []\n",
        "for i in tqdm(range(100)):\n",
        "    scores.append(detect_head(model, prompt, detection_pattern=detection_pattern, exclude_bos=False, exclude_current_token=True, error_measure=\"abs\"))\n",
        "scores = torch.stack(scores).mean(dim=0)\n",
        "plot_head_detection_scores(scores, title=\"Current Word Head Matches\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "AGvX96qf18H3"
      },
      "source": [
        "## Processing Many Prompts\n",
        "\n",
        "`detect_head` can also take more than one prompt. The resulting attention score is the mean of scores for each prompt."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 24,
      "metadata": {
        "id": "xKsRWJyi4nKb"
      },
      "outputs": [],
      "source": [
        "prompts = [\n",
        "    \"This is the first the test prompt.\",\n",
        "    \"This is another test prompt, being just a sequence of tokens.\",\n",
        "    \"If you're interested in mechanistic interpretability, this is how the sausage REALLY is made.\"\n",
        "]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "bDCNbAKn8O6c",
        "outputId": "3f3a69e9-6909-4d1b-ad14-52081f7b3fb3"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"b2982074-0e31-4e59-9284-0e928fabb655\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"b2982074-0e31-4e59-9284-0e928fabb655\")) {                    Plotly.newPlot(                        \"b2982074-0e31-4e59-9284-0e928fabb655\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.16188426315784454,0.002823923947289586,0.1288985013961792,0.14466561377048492,0.20654456317424774,0.03918367251753807,0.18338747322559357,0.30763113498687744,0.16847443580627441,0.14016640186309814,0.1253664344549179,0.13951462507247925],[0.3568015396595001,0.20963318645954132,0.17386376857757568,0.1282673329114914,0.14409492909908295,0.1185145378112793,0.12422195822000504,0.13218791782855988,0.13561616837978363,0.11285946518182755,0.17268244922161102,0.0343279093503952],[0.22819830477237701,0.11799445003271103,0.5887763500213623,0.31219711899757385,0.3139728605747223,0.3082503378391266,0.15516731142997742,0.19468097388744354,0.2997225821018219,0.3575190007686615,0.19085516035556793,0.1284373551607132],[0.07884027808904648,0.14090649783611298,0.37449514865875244,0.3634813725948334,0.08599424362182617,0.12028282880783081,0.32194265723228455,0.39816224575042725,0.2800182104110718,0.21907174587249756,0.13068385422229767,0.2543697655200958],[0.23509669303894043,0.2819938659667969,0.12271996587514877,0.28165629506111145,0.1179126724600792,0.20867566764354706,0.16058485209941864,0.20450665056705475,0.0927971825003624,0.15127387642860413,0.08719432353973389,0.9213631749153137],[0.08315619826316833,0.07763434946537018,0.20021028816699982,0.1631775051355362,0.19383548200130463,0.08268756419420242,0.2792682945728302,0.16048428416252136,0.09039705991744995,0.08870890736579895,0.16288234293460846,0.08901631087064743],[0.24115361273288727,0.11003191024065018,0.09119042754173279,0.09668155759572983,0.13394291698932648,0.1344429850578308,0.09180101752281189,0.15998393297195435,0.29044362902641296,0.07842478156089783,0.08471959084272385,0.2158702164888382],[0.2925063371658325,0.08629968017339706,0.07838237285614014,0.1303257793188095,0.10977789759635925,0.12118124216794968,0.09124282747507095,0.0803285762667656,0.19949126243591309,0.1347789615392685,0.0803055539727211,0.08003737777471542],[0.09742894768714905,0.08187402784824371,0.11326751857995987,0.09389842301607132,0.15491248667240143,0.1789555549621582,0.08987244218587875,0.24977760016918182,0.1333598494529724,0.10856479406356812,0.10288121551275253,0.08827092498540878],[0.14696048200130463,0.081753671169281,0.10250238329172134,0.2723653316497803,0.08316924422979355,0.0917249321937561,0.08624628186225891,0.09927653521299362,0.09505510330200195,0.08647056668996811,0.18500174582004547,0.08054942637681961],[0.1014685332775116,0.0883830264210701,0.09076711535453796,0.09248312562704086,0.11905821412801743,0.1342533379793167,0.09788057953119278,0.09766372293233871,0.08131682872772217,0.1900208592414856,0.0886608436703682,0.16996097564697266],[0.15588566660881042,0.09443841129541397,0.08812793344259262,0.16040129959583282,0.10796019434928894,0.091258704662323,0.08676495403051376,0.09504152089357376,0.1899704933166504,0.08892563730478287,0.1379389464855194,0.1511063575744629]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Previous token head; average across 3 prompts\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('b2982074-0e31-4e59-9284-0e928fabb655');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(model, prompts, \"previous_token_head\", error_measure=\"abs\")\n",
        "plot_head_detection_scores(head_scores, title=\"Previous token head; average across 3 prompts\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vzsyyU892l1m"
      },
      "source": [
        "L4H11 emerges again as the dominant head, exactly as expected."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "50VyBU3u408u"
      },
      "source": [
        "What about duplicate token heads?"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 26,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "a2Tvp9-a4oZC",
        "outputId": "d1cd9693-cebc-4b03-edbf-320eeb8b4084"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"d90591d7-f280-4953-be15-124bb2cbf87c\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"d90591d7-f280-4953-be15-124bb2cbf87c\")) {                    Plotly.newPlot(                        \"d90591d7-f280-4953-be15-124bb2cbf87c\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.0011233723489567637,0.027267659083008766,0.002946089953184128,0.005493770819157362,0.00451171537861228,0.019756413996219635,0.000588323688134551,0.005268637556582689,0.01463216170668602,0.005198679398745298,0.009358490817248821,0.004805959761142731],[0.0035103249829262495,0.0032356667798012495,0.007496751844882965,0.004537762608379126,0.004079228732734919,0.00502689927816391,0.0026617124676704407,0.0031993265729397535,0.0058091748505830765,0.004280661698430777,0.008642095141112804,0.023468634113669395],[0.001305588404648006,0.0029992673080414534,0.00018283608369529247,0.0020738206803798676,0.0024892836809158325,0.0011784253874793649,0.0030256451573222876,0.007133437320590019,0.0011500833788886666,0.0007830735412426293,0.004839754197746515,0.0024067505728453398],[0.0012606572126969695,0.0024684788659214973,0.0009068157523870468,0.00028745908639393747,0.0007525678374804556,0.002033783355727792,0.0010384307242929935,0.0006683766259811819,0.0011192806996405125,0.0016112179728224874,0.002452226122841239,0.00037800148129463196],[0.0019396659918129444,0.0005641563911922276,0.0019130933796986938,0.0004228235920891166,0.001376971136778593,0.0009577323216944933,0.0011361116776242852,0.0008641164749860764,0.00014961151464376599,0.00173727807123214,0.00107818644028157,7.292555231561137e-14],[8.265155338449404e-05,1.4038532469839993e-07,0.0008343210793100297,0.0014892900362610817,0.0006385748856700957,2.8836939236498438e-05,6.0404186115192715e-06,0.0002081064012600109,4.1445568058406934e-05,0.0003993819991592318,0.0002457024820614606,0.0011064474238082767],[0.001963213784620166,0.0001419207692379132,0.0009175835293717682,0.0003427473420742899,0.0013546384871006012,0.0009578443132340908,0.0009698329376988113,0.0011199656873941422,0.000927703978959471,3.6283706776885083e-06,0.00013258827675599605,0.0015376053052023053],[0.00011526015441631898,3.961416587117128e-05,2.4641246909595793e-06,0.0004013105935882777,0.0002151720691472292,0.00036943028680980206,0.00024681523791514337,1.642249117139727e-05,0.0015126978978514671,0.0009610216948203743,3.4132648579543456e-05,3.1994484743336216e-05],[0.0021424763835966587,1.5182497918431181e-05,0.002073281444609165,0.00020852191664744169,0.00048670507385395467,0.0010049822740256786,0.00013543013483285904,0.001171790761873126,0.00036822151741944253,0.0006251456798054278,0.0007659564143978059,0.00030346534913405776],[0.0003640612121671438,0.0001222945429617539,9.197709005093202e-05,0.0014104010770097375,1.74357137439074e-05,0.0004848809912800789,1.1230368727410678e-05,0.00026427555712871253,0.00019956678443122655,5.164195317775011e-05,0.00036299394560046494,0.00010582399409031495],[0.0005406789132393897,0.00014281690528150648,0.00025887112133204937,0.0005790966679342091,0.0010788501240313053,0.001064244075678289,0.0011353337904438376,0.000760702125262469,4.937747144140303e-05,0.0007043335936032236,0.00011824446119135246,0.0014881532406434417],[0.0050803967751562595,0.0009172582067549229,0.0003803072322625667,0.0036320164799690247,0.0007131153834052384,0.0002755882451310754,0.00014570353960152715,0.00037782941944897175,0.008856897242367268,0.00013637573283631355,0.0011008185101673007,0.0013881291961297393]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Duplicate token head; average across 3 prompts\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('d90591d7-f280-4953-be15-124bb2cbf87c');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(model, prompts, \"duplicate_token_head\", error_measure=\"abs\")\n",
        "plot_head_detection_scores(head_scores, title=\"Duplicate token head; average across 3 prompts\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JeKiWg41423q"
      },
      "source": [
        "Nothing but this should be expected, in hindsight, since our prompts don't contain too many duplicate tokens. Let's try three other prompts that do."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 27,
      "metadata": {
        "id": "afe4NxXM5ESp"
      },
      "outputs": [],
      "source": [
        "prompts = [\n",
        "    \"one two three one two three one two three\",\n",
        "    \"1 2 3 4 5 1 2 3 4 1 2 3 1 2 3 4 5 6 7\",\n",
        "    \"green ideas sleep furiously; green ideas don't sleep furiously\"\n",
        "]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 28,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "0LpotLqt5TRj",
        "outputId": "d1ea2496-93e7-4e9c-c915-708d279cd699"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"1c7b500d-df96-419d-8fcb-f74957f0604a\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"1c7b500d-df96-419d-8fcb-f74957f0604a\")) {                    Plotly.newPlot(                        \"1c7b500d-df96-419d-8fcb-f74957f0604a\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.02397620677947998,0.24333171546459198,0.03439174219965935,0.021952228620648384,0.05449114367365837,0.26917222142219543,0.059751156717538834,0.02555110491812229,0.05073240026831627,0.039533551782369614,0.11086731404066086,0.035950202494859695],[0.012808085419237614,0.023744381964206696,0.04648129642009735,0.031328096985816956,0.03771020472049713,0.02392107993364334,0.03560521826148033,0.023533983156085014,0.028033656999468803,0.03275194391608238,0.0633644089102745,0.19645096361637115],[0.02540658228099346,0.008584790863096714,0.0015488875797018409,0.010914540849626064,0.004771340172737837,0.010699001140892506,0.026478826999664307,0.040650106966495514,0.01189112663269043,0.010512019507586956,0.045468833297491074,0.01844440959393978],[0.14477986097335815,0.007943348959088326,0.005182888824492693,0.003321318654343486,0.014424617402255535,0.009262338280677795,0.011862039566040039,0.004428003914654255,0.007738329004496336,0.011844758875668049,0.028301343321800232,0.010690049268305302],[0.005743748042732477,0.012432236224412918,0.02163335122168064,0.007775434758514166,0.011922975070774555,0.0030307509005069733,0.017892928794026375,0.04278576001524925,0.013589872978627682,0.008066712878644466,0.006838344503194094,3.1572192256135168e-06],[0.0300280824303627,0.013597176410257816,0.00956028327345848,0.031979385763406754,0.01947723515331745,0.01171859446913004,0.012441237457096577,0.003187107853591442,0.011738193221390247,0.0174334105104208,0.0226981770247221,0.0362868532538414],[0.01765667460858822,0.025898976251482964,0.0075435154139995575,0.01570979319512844,0.02475748211145401,0.0236772820353508,0.037924814969301224,0.03787584602832794,0.01308919582515955,0.0759502425789833,0.010374323464930058,0.024149978533387184],[0.01662624441087246,0.01221627090126276,0.012104715220630169,0.014484149403870106,0.007345162332057953,0.02665163390338421,0.027033483609557152,0.0186985544860363,0.030151834711432457,0.010571825318038464,0.0668734610080719,0.038674235343933105],[0.013145999051630497,0.044014353305101395,0.014918840490281582,0.010512403212487698,0.0054276022128760815,0.03133096918463707,0.03643018379807472,0.00963016226887703,0.05230051651597023,0.016240764409303665,0.026206662878394127,0.01232586894184351],[0.014687501825392246,0.04806353151798248,0.011689533479511738,0.02959972806274891,0.006303983274847269,0.02534145675599575,0.008816775865852833,0.010069997049868107,0.0028156880289316177,0.03393140435218811,0.012749823741614819,0.006270490121096373],[0.011191527359187603,0.038580555468797684,0.0282991211861372,0.01663738675415516,0.018194546923041344,0.02309202216565609,0.006488102022558451,0.03456634655594826,0.03747814521193504,0.004284757189452648,0.011985649354755878,0.02539091370999813],[0.062220800668001175,0.019954176619648933,0.012045289389789104,0.02734450437128544,0.021417194977402687,0.022049227729439735,0.008052685298025608,0.01355746854096651,0.06625713407993317,0.009157839231193066,0.027595536783337593,0.029886847361922264]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Duplicate token head; average across 3 prompts\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('1c7b500d-df96-419d-8fcb-f74957f0604a');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(model, prompts, \"duplicate_token_head\", exclude_bos=False, exclude_current_token=False, error_measure=\"abs\")\n",
        "plot_head_detection_scores(head_scores, title=\"Duplicate token head; average across 3 prompts\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9cxe4I5V4wya"
      },
      "source": [
        "3 or 4 heads seem to do something that we would expected from a duplicate token head but the signal is not very strong. You can tweak the `exclude_bos` and `exclude_current_token` flags if you want, but it doesn't change much."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GrNd4zSw6FxL"
      },
      "source": [
        "Let's hunt for induction heads now!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 34,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "ixfjDS4n6Jd7",
        "outputId": "ce750192-3c4f-40bf-f6b7-e7423ec38ada"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"d4ac4093-1085-4f66-99ef-6521d9271f93\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"d4ac4093-1085-4f66-99ef-6521d9271f93\")) {                    Plotly.newPlot(                        \"d4ac4093-1085-4f66-99ef-6521d9271f93\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[0.028896650299429893,0.006047621835023165,0.03970715031027794,0.016188861802220345,0.04178859293460846,0.003243032842874527,0.0719306543469429,0.05249376595020294,0.06730972230434418,0.046413615345954895,0.04266245290637016,0.041676998138427734],[0.07421528548002243,0.047864943742752075,0.05689021572470665,0.03435598686337471,0.041421882808208466,0.06820859760046005,0.03936413675546646,0.03142102062702179,0.03147648274898529,0.03714052215218544,0.06915184110403061,0.020500997081398964],[0.053593311458826065,0.011845733039081097,0.02960474230349064,0.03894514963030815,0.049983784556388855,0.03857282176613808,0.04189431667327881,0.05688195303082466,0.04072584956884384,0.042535144835710526,0.05690307542681694,0.02472301386296749],[0.003917158115655184,0.01900329627096653,0.028489673510193825,0.025173963978886604,0.02549302764236927,0.012236632406711578,0.03638404980301857,0.03158534690737724,0.030725577846169472,0.021498799324035645,0.04020729288458824,0.03466212376952171],[0.015039116144180298,0.03305191919207573,0.018448740243911743,0.022443192079663277,0.011157098226249218,0.008066028356552124,0.03541906923055649,0.04622240364551544,0.03680512309074402,0.01635112427175045,0.03802961856126785,0.016027580946683884],[0.10208263993263245,0.16403056681156158,0.03088570199906826,0.045300934463739395,0.030110390856862068,0.2453325390815735,0.016737721860408783,0.0060740746557712555,0.12434953451156616,0.03744890168309212,0.011383995413780212,0.033234450966119766],[0.022611992433667183,0.04389975592494011,0.009435851126909256,0.021721497178077698,0.02634144015610218,0.0323694609105587,0.0451614111661911,0.037222202867269516,0.03397856280207634,0.24895398318767548,0.02578914724290371,0.028068460524082184],[0.020726101472973824,0.0344649963080883,0.04111428186297417,0.02473791129887104,0.010272246785461903,0.028780678287148476,0.047431185841560364,0.03513757884502411,0.03408512845635414,0.016993733122944832,0.20606662333011627,0.05927732214331627],[0.013737071305513382,0.11669806391000748,0.023649374023079872,0.019497115164995193,0.0058131166733801365,0.03269531950354576,0.07560193538665771,0.015770303085446358,0.07270892709493637,0.01568826287984848,0.04748893901705742,0.011324845254421234],[0.019769912585616112,0.05625047907233238,0.012647074647247791,0.03543737903237343,0.01024834904819727,0.035016003996133804,0.03563442826271057,0.029515715315937996,0.004474338609725237,0.08649969100952148,0.010249006561934948,0.02783658541738987],[0.01751413755118847,0.054381951689720154,0.03228127956390381,0.05004999041557312,0.026242570951581,0.022916650399565697,0.012911121360957623,0.11209282279014587,0.045918434858322144,0.005699923262000084,0.01970244199037552,0.04110514745116234],[0.06183802708983421,0.024498188868165016,0.013983485288918018,0.029931209981441498,0.027844058349728584,0.02529039792716503,0.009695347398519516,0.018166271969676018,0.05895465984940529,0.020387357100844383,0.06053429841995239,0.04203611612319946]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Duplicate token head; average across 3 prompts\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('d4ac4093-1085-4f66-99ef-6521d9271f93');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "head_scores = detect_head(model, prompts, \"induction_head\", exclude_bos=False, exclude_current_token=False, error_measure=\"abs\")\n",
        "plot_head_detection_scores(head_scores, title=\"Duplicate token head; average across 3 prompts\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JDL4I2hj6P5z"
      },
      "source": [
        "Similarly, at least on average.\n",
        "\n",
        "Try running the script on different prompts and see if you can get high values for duplicate token or induction heads."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Ys0pdGBI6min"
      },
      "source": [
        "## Why not element-wise multiplication - robustness against [Goodharting](https://en.wikipedia.org/wiki/Goodhart%27s_law)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TtFepOB474yd"
      },
      "source": [
        "Initially, the error measure was not the mean element-wise absolute value error (normalized to the number of rows) but the mean [element-wise product](https://en.wikipedia.org/wiki/Hadamard_product_(matrices)). However, it had its problems, such as susceptibility to Goodharting. You can specify a pattern consisting of all ones and in this way achieve a perfect match for all layers and heads in the model.\n",
        "\n",
        "More generally, using element-wise product causes the score to go down when we narrow our hypothesis. We can get a maximum score by just predicting 1 for everything. "
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 30,
      "metadata": {
        "id": "QAsossB28q7v"
      },
      "outputs": [],
      "source": [
        "prompt = \"The head detector feature for TransformerLens allows users to check for various common heads automatically, reducing the cost of discovery.\"\n",
        "seq_len = len(model.to_str_tokens(prompt))\n",
        "# torch.tril to make the pattern lower triangular\n",
        "ones_detection_pattern = torch.tril(torch.ones(seq_len, seq_len).to(device))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 31,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "5BCWs0QX61gH",
        "outputId": "3e950264-d6f7-4d5d-a0f3-570aa4a1e3e8"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"d7df050e-934f-4936-a37e-d1ba2b16a8e6\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"d7df050e-934f-4936-a37e-d1ba2b16a8e6\")) {                    Plotly.newPlot(                        \"d7df050e-934f-4936-a37e-d1ba2b16a8e6\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[1.0,1.0,1.0,0.9999999403953552,1.0,1.0,0.9999998807907104,1.0000001192092896,1.0,1.0,0.9999999403953552,0.9999999403953552],[1.0,1.0,0.9999999403953552,1.0,1.0,1.0,1.0000001192092896,1.0,1.0,1.0000001192092896,1.0,1.0],[1.0,0.9999999403953552,0.9999998807907104,1.0,1.0,1.0,1.0,0.9999999403953552,1.0,1.0,1.0,1.0],[1.0,1.0,1.0,0.9999999403953552,1.0,1.0000001192092896,1.0000001192092896,1.0,1.0,0.9999998807907104,1.0,1.0],[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0000001192092896,0.9999999403953552],[1.0,1.0000001192092896,0.9999999403953552,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0000001192092896],[1.0,1.0,0.9999999403953552,1.0000001192092896,1.0,0.9999999403953552,1.0000001192092896,1.0,1.0,1.0,1.0,1.0],[1.0,0.9999999403953552,1.0,1.0000001192092896,1.0,1.0,1.0,1.0,1.0,1.0,1.0000001192092896,1.0000001192092896],[1.0,0.9999998807907104,1.0,0.9999998211860657,1.0,1.0,1.0000001192092896,1.0,1.0,1.0,1.0,1.0],[1.0,1.0,1.0,0.9999998807907104,1.0,0.9999999403953552,0.9999999403953552,1.0,1.0,1.0000001192092896,1.0,1.0],[1.0,1.0,1.0000001192092896,1.0,1.0,0.9999999403953552,1.0,1.0,1.0,1.0000001192092896,1.0,1.0000001192092896],[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0000001192092896]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Transformers Have Now Been Solved, We Can All Go Home\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('d7df050e-934f-4936-a37e-d1ba2b16a8e6');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "ones_head_scores = detect_head(\n",
        "    model, \n",
        "    prompt, \n",
        "    ones_detection_pattern, \n",
        "    exclude_bos=True, \n",
        "    exclude_current_token=True, \n",
        ")\n",
        "plot_head_detection_scores(ones_head_scores, title=\"Transformers Have Now Been Solved, We Can All Go Home\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "PaYJhx6W8l90"
      },
      "source": [
        "The new error measure also achieves uniform score but this time its uniformly extremely negative because **not a single head in the model matches this pattern**.\n",
        "\n",
        "*(It's true that the scores descend below -9 whereas in theory they should remain within the (-1, 1) range. It's not yet clear if that matters for real-world uses.)*\n",
        "\n",
        "An alternative would be to demand that *predictions add up to 1 for each row* but that seems unnecessarily nitpicky considering that your score will get reduced in general for not doing that anyway.\n",
        "\n",
        "Mean squared errors have also bean tried before converging on the absolute ones. The problem with MSE is that the scores get lower as attention gets more diffuse. Error value of 1 would become 1, 0.5 would become 0.25 etc."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 32,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "U722j1mJ9TbC",
        "outputId": "8525577e-d060-4cf9-c355-e74cda383ae8"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script src=\"https://cdn.plot.ly/plotly-2.18.2.min.js\"></script>                <div id=\"a3a9a680-b39d-48a9-98e6-3f5693a94d6b\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"a3a9a680-b39d-48a9-98e6-3f5693a94d6b\")) {                    Plotly.newPlot(                        \"a3a9a680-b39d-48a9-98e6-3f5693a94d6b\",                        [{\"coloraxis\":\"coloraxis\",\"name\":\"0\",\"z\":[[-9.414999961853027,-9.980999946594238,-9.569000244140625,-9.885000228881836,-9.684000015258789,-9.866999626159668,-9.371999740600586,-9.390000343322754,-9.444000244140625,-9.482999801635742,-9.538000106811523,-9.45199966430664],[-9.300999641418457,-9.406000137329102,-9.407999992370605,-9.661999702453613,-9.491999626159668,-9.590999603271484,-9.557999610900879,-9.46500015258789,-9.545999526977539,-9.585000038146973,-9.265999794006348,-9.892999649047852],[-9.414999961853027,-9.586000442504883,-9.3149995803833,-9.333999633789062,-9.52400016784668,-9.36299991607666,-9.597000122070312,-9.413000106811523,-9.329999923706055,-9.309000015258789,-9.395999908447266,-9.75100040435791],[-9.958999633789062,-9.560999870300293,-9.414999961853027,-9.744000434875488,-9.906000137329102,-9.690999984741211,-9.446000099182129,-9.451000213623047,-9.463000297546387,-9.651000022888184,-9.833999633789062,-9.5],[-9.579000473022461,-9.602999687194824,-9.815999984741211,-9.593999862670898,-9.854999542236328,-9.6850004196167,-9.664999961853027,-9.758000373840332,-9.920999526977539,-9.621000289916992,-9.907999992370605,-9.121000289916992],[-10.0,-10.038999557495117,-9.730999946594238,-9.48900032043457,-9.664999961853027,-9.946000099182129,-9.875,-9.836999893188477,-9.902999877929688,-9.859000205993652,-9.633999824523926,-9.880000114440918],[-9.565999984741211,-9.968999862670898,-9.807000160217285,-9.800000190734863,-9.604999542236328,-9.789999961853027,-9.942000389099121,-9.567000389099121,-9.67199993133545,-10.027999877929688,-9.973999977111816,-9.670000076293945],[-9.706999778747559,-9.961999893188477,-10.03499984741211,-9.770000457763672,-9.840999603271484,-9.732000350952148,-9.883000373840332,-10.02299976348877,-9.776000022888184,-9.765000343322754,-10.020999908447266,-9.998000144958496],[-9.845000267028809,-10.019000053405762,-9.645999908447266,-9.819999694824219,-9.76099967956543,-9.597999572753906,-9.984999656677246,-9.687999725341797,-9.503999710083008,-9.788000106811523,-9.795999526977539,-9.774999618530273],[-9.652000427246094,-9.996999740600586,-9.619999885559082,-9.616000175476074,-9.970999717712402,-9.781999588012695,-9.963000297546387,-9.8149995803833,-9.854999542236328,-9.947999954223633,-9.753999710083008,-9.994000434875488],[-9.663000106811523,-9.920999526977539,-9.928999900817871,-9.875,-9.722000122070312,-9.777000427246094,-9.890999794006348,-9.79800033569336,-9.996000289916992,-9.675000190734863,-9.864999771118164,-9.835000038146973],[-9.397000312805176,-9.74899959564209,-9.864999771118164,-9.564000129699707,-9.755999565124512,-9.890999794006348,-9.859999656677246,-9.829000473022461,-9.305999755859375,-9.939000129699707,-9.694999694824219,-9.522000312805176]],\"type\":\"heatmap\",\"xaxis\":\"x\",\"yaxis\":\"y\",\"hovertemplate\":\"x: %{x}<br>y: %{y}<br>color: %{z}<extra></extra>\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"Head\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"autorange\":\"reversed\",\"title\":{\"text\":\"Layer\"}},\"coloraxis\":{\"colorscale\":[[0.0,\"rgb(103,0,31)\"],[0.1,\"rgb(178,24,43)\"],[0.2,\"rgb(214,96,77)\"],[0.3,\"rgb(244,165,130)\"],[0.4,\"rgb(253,219,199)\"],[0.5,\"rgb(247,247,247)\"],[0.6,\"rgb(209,229,240)\"],[0.7,\"rgb(146,197,222)\"],[0.8,\"rgb(67,147,195)\"],[0.9,\"rgb(33,102,172)\"],[1.0,\"rgb(5,48,97)\"]],\"cmid\":0.0,\"cmin\":-1,\"cmax\":1},\"title\":{\"text\":\"Transformers Have Not Been Solved Yet, Get Back To Work!\"}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('a3a9a680-b39d-48a9-98e6-3f5693a94d6b');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "ones_head_scores = detect_head(\n",
        "    model, \n",
        "    prompt, \n",
        "    ones_detection_pattern, \n",
        "    exclude_bos=True, \n",
        "    exclude_current_token=True, \n",
        "    error_measure=\"abs\" # we specify the error measure here\n",
        ")\n",
        "plot_head_detection_scores(ones_head_scores, title=\"Transformers Have Not Been Solved Yet, Get Back To Work!\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hcXmbyWJ6knn"
      },
      "source": [
        "## Further improvements"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fkxMLVehaZOj"
      },
      "source": [
        "**Performance for large distributions** isn't as good as it could be. The head detector could be rewritten to support taking in a list of sequences and performing these computations in parallel, but 1000 sequences per minute is certainly adequate for most use cases. If having this be faster would help your research, please write up an issue on TransformerLens, mention it on the Open Source Mechanistic Interpretability Slack, or e-mail jaybaileycs@gmail.com."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "zXrc4KA5A5c9"
      },
      "source": [
        "### Other\n",
        "\n",
        "- Extending to few-shot learning/translation heads\n",
        "- More pre-specified heads?\n",
        "- For inspiration, see [this post from Neel](https://www.lesswrong.com/s/yivyHaCAmMJ3CqSyj/p/btasQF7wiCYPsr5qw)"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "provenance": []
    },
    "gpuClass": "standard",
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.10.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
